Saldos iniciales, cambios en OC numero de remision, validacion cultivo 158,

This commit is contained in:
Oscar Irigoyen
2022-09-22 18:45:24 -07:00
parent 31fc12d0c5
commit 218ecb14a7
14 changed files with 605 additions and 90 deletions

View File

@@ -2,6 +2,8 @@
using System.Web.UI.WebControls;
using Extensiones;
using System.Data;
using static Extensiones.ModExtensiones;
using System.Collections.Generic;
using System.IO;
using ListItem = System.Web.UI.WebControls.ListItem;
using DocumentFormat.OpenXml.Spreadsheet;
@@ -13,6 +15,25 @@ public partial class Ventas_RepLineasAdicionales : ClsPaginas
private int CveLineaAdicional
{
get { return (ViewState["CveLineaAdicional"] == null) ? 0 : int.Parse(ViewState["CveLineaAdicional"].ToString()); }
set { ViewState["CveLineaAdicional"] =(int) value; }
}
private int TipoLinea
{
get { return (ViewState["TipoLinea"] == null) ? 1: int.Parse(ViewState["TipoLinea"].ToString()); }
set { ViewState["TipoLinea"] = (int)value; }
}
private DataTable DTDatosGvLineasAdicionales
{
get
{
if (ViewState["DTDatosGvLineasAdicionales"] == null)
{
ViewState["DTDatosGvLineasAdicionales"] = new DataTable();
}
return (DataTable)ViewState["DTDatosGvLineasAdicionales"];
}
set { ViewState["DTDatosGvLineasAdicionales"] = (DataTable)value; }
}
@@ -33,6 +54,7 @@ public partial class Ventas_RepLineasAdicionales : ClsPaginas
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InicializaValores();
@@ -43,23 +65,20 @@ public partial class Ventas_RepLineasAdicionales : ClsPaginas
private void InicializaValores()
{
if (Request["OP"] != null && Request["OP"].ToString() == "PO")
if (Request["OP"] != null && Request["OP"].ToString() == "PO")
{
DVProveedor1.Visible = true;
DVProveedor2.Visible = true;
GvLineasAdicionales.Columns[8].Visible = true;
TipoLinea = 2;
LtlEncabezado.Text = "Reporte PO";
}
//Carga Clientes
DdlClientes.DataSource = get_GlobalDTCliente(UsuarioActual.CveEmpresa, -1);
//Carga Clientes
DdlClientes.DataSource = get_GlobalDTCliente(UsuarioActual.CveEmpresa, -1);
DdlClientes.DataBind();
if(UsuarioActual.Empresa.Funcionalidad(105) == "1") {
DdlProveedor.setEsWebService(true);
DdlProveedor.Attributes.Add("data-metodo", "getproveedores");
DdlProveedor.SelectedText = "Todos";
DdlProveedor.setEsWebService(true);
DdlProveedor.Attributes.Add("data-metodo", "getproveedores");
DdlProveedor.SelectedText = "Todos";
@@ -85,17 +104,19 @@ public partial class Ventas_RepLineasAdicionales : ClsPaginas
protected void BtnConsultar_Click(object sender, EventArgs e)
{
CargaDatos();
}
private void CargaDatos()
{
DTDatosGvLineasAdicionales = new DataTable();
LnkDescargaExcel.Visible = false;
ClsVentas objVentas = new ClsVentas();
ClsVentas objVentas = new ClsVentas();
int CveProveedor = DdlProveedor.SelectedValue.ToEntero() > 0 ? DdlProveedor.SelectedValue.ToEntero() : -1;
if(objVentas.GetLineasAdicionales(-1,DdlClientes.SelectedValue.ToEntero(),CveProveedor, TipoLinea, -1,txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), DdlEstatus.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa)){
GvLineasAdicionales.DataSource = objVentas.DtResultados;
if( objVentas.DtResultados.Rows.Count > 0)
{
@@ -240,15 +261,62 @@ public partial class Ventas_RepLineasAdicionales : ClsPaginas
errorCambioEstatus = true;
}
if (!errorCambioEstatus)
if (!errorCambioEstatus)
{
CargaDatos();
}
objVentas.Dispose();
}
}
protected void LnkDescargaExcel_Click(object sender, EventArgs e)
{
GridView gvTemp = GvLineasAdicionales;
{
gvTemp.Columns[8].Visible = false;
gvTemp.ExportToExcelx( TipoLinea == 1 ? "RepLienasAdicionales":"RepPO");
}
protected void GvLineasAdicionales_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
if(e.Row.DataKey("CveEstatus").ToEntero().Contiene(2))
{
e.Row.FCLinkButton("LnkCambiarEstatus").Visible = true;
}
if (e.Row.DataKey("CveEstatus").ToEntero() == 3)
{
e.Row.FCLinkButton("LnkCargarComprobante").Visible = false;
}
if (e.Row.DataKey("Comprobante").Length > 0)
{
FileInfo fi = new FileInfo($@"{UsuarioActual.Empresa.Ruta}\LineasAdicionales\{e.Row.DataKey("Comprobante")}");
LinkButton LnkDescargaComprobante = e.Row.FCLinkButton("LnkDescargaComprobante");
if (fi.Exists)
{
LnkDescargaComprobante.Visible = true;
ScriptManager.GetCurrent(this).RegisterPostBackControl(LnkDescargaComprobante);
}
}
}
}
protected void LnkDescargaComprobante_Click(object sender, EventArgs e)
{
GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
string Comprobante = GvRow.DataKey("Comprobante");
FileInfo fi = new FileInfo($@"{UsuarioActual.Empresa.Ruta}\LineasAdicionales\{Comprobante}");
if (fi.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name);
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "text/octet-stream";
Response.Flush();
Response.TransmitFile(fi.FullName);