-- ajustes para rep vencimientos

This commit is contained in:
2024-05-29 07:41:43 -07:00
parent 148df4f88f
commit 895fec5199
2 changed files with 17 additions and 299 deletions

View File

@@ -88,58 +88,20 @@ public partial class Ventas_RepVencimientosCredito : ClsPaginas
private void CargaDatos()
{
DTDatosGvD = new DataTable();
LnkDescargaExcel.Visible = false;
ClsVentas objVentas = new ClsVentas();
DTDatosGvD = new DataTable();
LnkDescargaExcel.Visible = false;
int CveProveedor = -1;
if(TipoLinea == 1)
ClsVentas objVentas = new ClsVentas();
if (objVentas.GetLineasAdicionalesVencimientos( DdlClientes.SelectedValue.ToEntero(), 1, txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), 1, UsuarioActual.CveEmpresa))
{
GvD.DataSource = objVentas.DtResultados;
if (objVentas.DtResultados.Rows.Count > 0)
{
DTDatosGvD = objVentas.DtResultados;
LnkDescargaExcel.Visible = true;
if (objVentas.GetLineasAdicionalesVencimientos( DdlClientes.SelectedValue.ToEntero(), -1, txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), 1, UsuarioActual.CveEmpresa))
{
}
GvD.DataSource = objVentas.DtResultados;
if (objVentas.DtResultados.Rows.Count > 0)
{
DTDatosGvD = objVentas.DtResultados;
{
GvD.DataSource = null;
}
}
else
{
if (DdlAgrupador.SelectedValue.ToEntero()== 1){
GvLAPO.Columns[0].HeaderText = "Comercializador";
}
else
{
GvLAPO.Columns[0].HeaderText = "Cliente";
}
if (objVentas.RepLineasAdicionales(DdlAgrupador.SelectedValue.ToEntero(), -1, DdlClientes.SelectedValue.ToEntero(), CveProveedor, 2, -1, MinFecha, MaxFecha, DdlEstatus.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa))
{
GvLAPO.DataSource = objVentas.DtResultados;
if (objVentas.DtResultados.Rows.Count > 0)
{
DTDatosGvD = objVentas.DtResultados;
LnkDescargaExcel.Visible = true;
UpAcciones.Update();
}
}
else
{
LnkDescargaExcel.Visible = true;
UpAcciones.Update();
}
}
}
objVentas.Dispose();
@@ -155,116 +117,7 @@ public partial class Ventas_RepVencimientosCredito : ClsPaginas
CveLineaAdicional = GvRow.DataKey("CveLineaAdicional").ToString().ToEntero();
CveVenta = GvRow.DataKey("CveVenta").ToString().ToEntero();
LineaAdicionalComprobante = GvRow.DataKey("LineaAdicionalComprobante").ToString();
RegistraScript("$('#ModalComprobante').modal('show');","");
}
protected void BtnAddComprobante_Click(object sender, EventArgs e)
{
bool errorCargaComprobante = false;
string FileExtension = "-1";
List<Archivo> filesgral = Anexo.getfiles().Archivos;
string filemove = "";
FileInfo fiNuevo;
DirectoryInfo df = new DirectoryInfo($@"{UsuarioActual.Empresa.Ruta}\LineasAdicionales\");
//Crea directorio si no existe
if (!df.Exists)
{
try
{
Directory.CreateDirectory(df.FullName);
}
catch
{
errorCargaComprobante = true;
}
}
//borrar archivo anterior
if((!errorCargaComprobante) && LineaAdicionalComprobante.Length > 0)
{
FileInfo fiAnterior = new FileInfo($@"{df.FullName}{LineaAdicionalComprobante}");
if (fiAnterior.Exists)
{
try
{
File.Delete(fiAnterior.FullName);
}
catch
{
errorCargaComprobante = true;
}
}
}
if(!errorCargaComprobante){
string RutaArchivoTemp = "";
foreach (Archivo fileItem in filesgral)
{
FileExtension = System.IO.Path.GetExtension(string.Format(@"{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "");
filemove = fileItem.filename;
RutaArchivoTemp = $@"{AppDomain.CurrentDomain.BaseDirectory}\Temp\{fileItem.filename}";
break;
}
if((!errorCargaComprobante) && RutaArchivoTemp.Length > 0)
{
fiNuevo = new FileInfo(RutaArchivoTemp);
if (fiNuevo.Exists)
{
try
{
if (File.Exists($@"{df.FullName}\{CveVenta}{fiNuevo.Extension}"))
{
File.Delete($@"{df.FullName}\{CveVenta}{fiNuevo.Extension}");
}
File.Move(fiNuevo.FullName, $@"{df.FullName}\{CveVenta}{fiNuevo.Extension}");
errorCargaComprobante = false;
}
catch
{
errorCargaComprobante = true;
}
if (!errorCargaComprobante)
{
ClsVentas objVentas = new ClsVentas();
if (!objVentas.UpdateVentaLineaAdicional(CveLineaAdicional, CveVenta, $@"{CveVenta}{fiNuevo.Extension}", -1, UsuarioActual.CveEmpresa))
{
errorCargaComprobante = true;
}
objVentas.Dispose();
}
}
}
}
if (!errorCargaComprobante)
{
CargaDatos();
Anexo.Text = "[]";
RegistraScript("$('#ModalComprobante').modal('hide');", "");
Alert("Comprobante actualizado correctamente.");
}
UpAddComprobancte.Update();
}
protected void LnkCambiarEstatus_Click(object sender, EventArgs e)
{
GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
int CveLineaAdicionalActualzarEstatus = GvRow.DataKey("CveLineaAdicional").ToEntero();
int CveVenta = GvRow.DataKey("CveVenta").ToEntero();
bool errorCambioEstatus = false;
ClsVentas objVentas = new ClsVentas();
if (!objVentas.UpdateVentaLineaAdicional(CveLineaAdicional, CveVenta, "", 2, UsuarioActual.CveEmpresa))
{
errorCambioEstatus = true;
}
if (!errorCambioEstatus)
{
RegistraScript("$('#ModalComprobante').modal('show');","");
}
@@ -273,14 +126,7 @@ public partial class Ventas_RepVencimientosCredito : ClsPaginas
protected void LnkDescargaExcel_Click(object sender, EventArgs e)
{
if(TipoLinea == 1)
{
GridView gvTemp = GvD;
//gvTemp.ExportToExcelX("RepLineasAdicionales" + NowADS().ToShortDateString());
gvTemp.ExportToExcelGembox("RepLineasAdicionales", UsuarioActual, "Rep Lineas Adicionales", AnchoImagen: 150);
}
else if(TipoLinea == 2)
{
GridView gvTemp = GvLAPO;
{
GridView gvTemp = GvD;
//gvTemp.ExportToExcelX("RepLineasAdicionales" + NowADS().ToShortDateString());
gvTemp.ExportToExcelGembox("RepLineasAdicionales", UsuarioActual, "Rep Lineas Adicionales", AnchoImagen: 150);
@@ -351,28 +197,6 @@ public partial class Ventas_RepVencimientosCredito : ClsPaginas
Response.ContentType = "text/octet-stream";
Response.Flush();
Response.TransmitFile(fi.FullName);
Response.End();
}
}
protected void GvLAPO_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Estatus")
{
GridViewRow GvRow = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
int CveLineaAdicionalActualizarEstatus = GvRow.DataKey("CveLineaAdicional").ToString().ToEntero();
int CveVenta = GvRow.DataKey("CveVenta").ToString().ToEntero();
bool errorCambioEstatus = false;
//int cveestatus = e.CommandArgument.ToEntero() + 2; //pasar al siguiente estatus
ClsVentas objVentas = new ClsVentas();
if (!objVentas.UpdateVentaLineaAdicional(CveLineaAdicionalActualizarEstatus, CveVenta,"", 2, UsuarioActual.CveEmpresa))
{
errorCambioEstatus = true;
}
objVentas.Dispose();
if (!errorCambioEstatus)
{
Response.End();
}
}