Commit inicial Ventas Productivo
This commit is contained in:
450
CGame/EntradaMateriaPrima.aspx.cs
Normal file
450
CGame/EntradaMateriaPrima.aspx.cs
Normal file
@@ -0,0 +1,450 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using Extensiones;
|
||||
using System.Data;
|
||||
using static Extensiones.ModExtensiones;
|
||||
using Microsoft.Reporting.WebForms;
|
||||
using System.Web.UI;
|
||||
|
||||
public partial class CATCorte : ClsPaginas
|
||||
{
|
||||
|
||||
#region Propiedades
|
||||
|
||||
private int CveCorte
|
||||
{
|
||||
get { return (ViewState["CveCorte"] == null) ? -1 : Convert.ToInt32(ViewState["CveCorte"]); }
|
||||
set { ViewState["CveCorte"] = value; }
|
||||
}
|
||||
private int CveOrdenCorte
|
||||
{
|
||||
get { return (ViewState["CveOrdenCorte"] == null) ? -1 : Convert.ToInt32(ViewState["CveOrdenCorte"]); }
|
||||
set { ViewState["CveOrdenCorte"] = value; }
|
||||
}
|
||||
private int Index
|
||||
{
|
||||
get { return (ViewState["Index"] == null) ? 0 : Convert.ToInt32(ViewState["Index"]); }
|
||||
set { ViewState["Index"] = value; }
|
||||
}
|
||||
private String Adjunto
|
||||
{
|
||||
get { return (ViewState["Adjunto"] == null) ? "-1" : (String)(ViewState["Adjunto"]); }
|
||||
set { ViewState["Adjunto"] = value; }
|
||||
}
|
||||
private int CveHuerta
|
||||
{
|
||||
get { return (ViewState["CveHuerta"] == null) ? 0 : Convert.ToInt32(ViewState["CveHuerta"]); }
|
||||
set { ViewState["CveHuerta"] = value; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
CveOrdenCorte = Request["CveOrdenCorte"] == null ? -1 : Request["CveOrdenCorte"].ToString().ToEntero();
|
||||
CveHuerta = Request["CveHuerta"] == null ? 0 : Request["CveHuerta"].ToString().ToEntero();
|
||||
txtFechaI.Text = DateTime.Now.AddMonths(-1).ToShortDateString();
|
||||
txtFechaF.Text = DateTime.Now.ToShortDateString();
|
||||
CargaMotivo();
|
||||
CargaOrdenCorte();
|
||||
CargaHuerta();
|
||||
CargaEmpaque();
|
||||
CargaBitacora();
|
||||
CargaFletes();
|
||||
if (CveHuerta > 0) { DdlHuertaFiltro.SelectedValueExist(CveHuerta); }
|
||||
CargaCorte();
|
||||
if (CveOrdenCorte > 0) { Agregar(); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Cargas
|
||||
protected void CargaCorte()
|
||||
{
|
||||
ClsCGame ObjCort = new ClsCGame();
|
||||
if (ObjCort.GetCorte(UsuarioActual.CveEmpresa, Estatus: DdlEstatus.SelectedValue.ToEntero(), CveHuerta: DdlHuertaFiltro.SelectedValue.ToEntero(), Opcion: 1,FechaI:txtFechaI.Text.ToDate(),FechaF:txtFechaF.Text.ToDate()))
|
||||
{
|
||||
GVCorte.DataSource = ObjCort.DtResultados;
|
||||
}
|
||||
ObjCort.Dispose();
|
||||
GVCorte.DataBind();
|
||||
upDatosCort.Update();
|
||||
}
|
||||
protected void CargaHuerta()
|
||||
{
|
||||
ClsCGame ObjCort = new ClsCGame();
|
||||
if (ObjCort.GetHuerta(UsuarioActual.CveEmpresa))
|
||||
{
|
||||
DdlHuertaFiltro.DataSource = ObjCort.DtResultados;
|
||||
DdlHuertaFiltro.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
}
|
||||
ObjCort.Dispose(); ;
|
||||
DdlHuertaFiltro.DataBind();
|
||||
UpFiltros.Update();
|
||||
}
|
||||
|
||||
protected void CargaOrdenCorte(int CveOrdenCorte = -1)
|
||||
{
|
||||
DdlOrdenCorte.Items.Clear();
|
||||
ClsCGame ObjCGame = new ClsCGame();
|
||||
if (ObjCGame.GetOrdenCorte(UsuarioActual.CveEmpresa))
|
||||
{
|
||||
if (CveOrdenCorte < 1)
|
||||
{
|
||||
DdlOrdenCorte.DataSource = ObjCGame.DtResultados.FiltraParametros("Disponible = 1");
|
||||
}
|
||||
else
|
||||
{
|
||||
DdlOrdenCorte.DataSource = ObjCGame.DtResultados.FiltraParametros(String.Format("Disponible = 1 OR CveOrdenCorte = {0}", CveOrdenCorte));
|
||||
}
|
||||
DdlOrdenCorte.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||||
}
|
||||
ObjCGame.Dispose();
|
||||
DdlOrdenCorte.DataBind();
|
||||
UPModalCort.Update();
|
||||
}
|
||||
|
||||
protected void CargaMotivo()
|
||||
{
|
||||
ClsCGame ObjCort = new ClsCGame();
|
||||
if (ObjCort.GetMotivoMerma(UsuarioActual.CveEmpresa))
|
||||
{
|
||||
DdlMotivo.DataSource = ObjCort.DtResultados;
|
||||
DdlMotivo.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||||
DdlMotivo.DataBind();
|
||||
}
|
||||
ObjCort.Dispose();
|
||||
UPModalCort.Update();
|
||||
}
|
||||
|
||||
private void CargaEmpaque()
|
||||
{
|
||||
ClsCGame ObjCGame = new ClsCGame();
|
||||
if (ObjCGame.GetEmpaques(UsuarioActual.CveEmpresa, -1, 1))
|
||||
{
|
||||
DdlEmpaque.DataSource = ObjCGame.DtResultados;
|
||||
DdlEmpaque.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||||
}
|
||||
ObjCGame.Dispose();
|
||||
DdlEmpaque.DataBind();
|
||||
}
|
||||
|
||||
private void CargaBitacora()
|
||||
{
|
||||
ClsCGame ObjCGame = new ClsCGame();
|
||||
if (ObjCGame.GetBitacora(UsuarioActual.CveEmpresa))
|
||||
{
|
||||
GvBitacora.DataSource = ObjCGame.DtResultados;
|
||||
}
|
||||
ObjCGame.Dispose();
|
||||
GvBitacora.DataBind();
|
||||
UpBitacora.Update();
|
||||
}
|
||||
|
||||
private void CargaFletes(int CveFlete = -1)
|
||||
{
|
||||
DdlFlete.Items.Clear();
|
||||
if (DdlOrdenCorte.SelectedValue.ToEntero() != -1)
|
||||
{
|
||||
ClsCGame ObjCGame = new ClsCGame();
|
||||
if (ObjCGame.GetFlete(UsuarioActual.CveEmpresa, CveOrdenCorte: DdlOrdenCorte.SelectedValue.ToEntero()))
|
||||
{
|
||||
if (CveFlete < 1)
|
||||
{
|
||||
DdlFlete.DataSource = ObjCGame.DtResultados.FiltraParametros("Peso IS NULL");
|
||||
}
|
||||
else
|
||||
{
|
||||
DdlFlete.DataSource = ObjCGame.DtResultados.FiltraParametros(String.Format("Peso IS NULL OR CveFlete = {0}", CveFlete));
|
||||
}
|
||||
}
|
||||
|
||||
ObjCGame.Dispose();
|
||||
}
|
||||
DdlFlete.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
||||
DdlFlete.DataBind();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Limpia Modal
|
||||
protected void LimpiaCorte()
|
||||
{
|
||||
TxtFecha.Text = DateTime.Now.ToString();
|
||||
TxtPeso.Text = "";
|
||||
DdlOrdenCorte.SelectedIndex = 0;
|
||||
TxtObservacion.Text = "";
|
||||
TxtModalAdjuntoArchivo.Text = "";
|
||||
TxtTicketBascula.Text = "";
|
||||
TxtPesoMerma.Text = "";
|
||||
DdlMotivo.SelectedIndex = 0;
|
||||
DdlFlete.SelectedIndex = 0;
|
||||
DdlEmpaque.SelectedIndex = 0;
|
||||
UPModalCort.Update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Botones
|
||||
protected void LnkEditarCort_Click(object sender, EventArgs e)
|
||||
{
|
||||
LimpiaCorte();
|
||||
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
||||
CveCorte = gvRow.DataKey("CveCorte").ToEntero();
|
||||
Index = gvRow.RowIndex;
|
||||
CargaOrdenCorte(gvRow.DataKey("CveOrdenCorte").ToEntero());
|
||||
DdlOrdenCorte.SelectedValueExist(gvRow.DataKey("CveOrdenCorte").ToEntero());
|
||||
TxtFecha.Text = gvRow.DataKey("Fecha");
|
||||
TxtPeso.Text = gvRow.DataKey("Peso");
|
||||
TxtObservacion.Text = gvRow.DataKey("Observacion");
|
||||
TxtTicketBascula.Text = gvRow.DataKey("TicketBascula");
|
||||
Adjunto = gvRow.DataKey("Adjunto");
|
||||
TxtPesoMerma.Text = gvRow.DataKey("PesoMerma");
|
||||
TxtModalAdjuntoArchivo.Text = "";
|
||||
DdlMotivo.SelectedValueExist(gvRow.DataKey("CveMotivo").ToEntero());
|
||||
CargaFletes(gvRow.DataKey("CveFlete").ToEntero());
|
||||
DdlFlete.SelectedValueExist(gvRow.DataKey("CveFlete").ToEntero());
|
||||
DdlEmpaque.SelectedValueExist(gvRow.DataKey("CveEmpaque").ToEntero());
|
||||
if (gvRow.DataKey("Adjunto").ToString() != "") { LnkDescargar.Visible = true; }
|
||||
this.RegistraScript("$('#DModalCorte').modal();");
|
||||
BtnCortADD.Visible = false;
|
||||
BtnCortEdit.Visible = true;
|
||||
UPModalCort.Update();
|
||||
}
|
||||
protected void LnkAgregarCort_Click(object sender, EventArgs e)
|
||||
{
|
||||
Agregar();
|
||||
}
|
||||
|
||||
protected void Agregar()
|
||||
{
|
||||
this.RegistraScript("$('#DModalCorte').modal();");
|
||||
LimpiaCorte();
|
||||
if (CveOrdenCorte > 0) { DdlOrdenCorte.SelectedValueExist(CveOrdenCorte); }
|
||||
BtnCortADD.Visible = true;
|
||||
BtnCortEdit.Visible = false;
|
||||
LnkDescargar.Visible = false;
|
||||
UPModalCort.Update();
|
||||
}
|
||||
protected void LnkAgregarBitacora_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.RegistraScript("$('#DModalBitacora').modal();");
|
||||
TxtComentario.Text = "";
|
||||
UpModalBitacora.Update();
|
||||
}
|
||||
protected void BtnCortADD_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Valida())
|
||||
{
|
||||
String Adjunto = "";
|
||||
if (TxtModalAdjuntoArchivo.getfiles().Archivos.Count > 0)
|
||||
{
|
||||
Archivo ArchivoAdjunto = TxtModalAdjuntoArchivo.getfiles().Archivos[0];
|
||||
Adjunto = DdlOrdenCorte.SelectedValue + "_" + ArchivoAdjunto.filenameO;
|
||||
}
|
||||
ClsCGame ObjCort = new ClsCGame();
|
||||
ObjCort.IniciaTransacSQL();
|
||||
bool Continuar = ObjCort.AddCorte(TxtFecha.Text.ToDate(), TxtPeso.Text.ToDouble(), TxtObservacion.Text, Adjunto, TxtTicketBascula.Text, TxtPesoMerma.Text.ToDouble(), DdlMotivo.SelectedValue.ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlOrdenCorte.SelectedValue.ToEntero(), DdlEmpaque.SelectedValue.ToEntero(), DdlFlete.SelectedValue.ToEntero());
|
||||
Continuar = ObjCort.UpdateFleteImporte(DdlOrdenCorte.SelectedValue.ToEntero(), TxtPeso.Text.ToDouble(), DdlFlete.SelectedValue.ToEntero());
|
||||
if (Continuar)
|
||||
{
|
||||
CveCorte = ObjCort.CveCorte;
|
||||
ObjCort.Commit();
|
||||
if (TxtModalAdjuntoArchivo.getfiles().Archivos.Count > 0)
|
||||
{
|
||||
GuardarAdjunto();
|
||||
}
|
||||
this.RegistraScript("$('#DModalCorte').modal('hide');");
|
||||
if (CveOrdenCorte > 0)
|
||||
{
|
||||
Alert("La entrada de materia prima se ha agregado correctamente", TipoMensaje.MsgInformacion, $"document.location.href=\"/CGame/RepOrdenCorteDetalle.aspx?CveOrdenCorte={CveOrdenCorte}\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
CargaCorte();
|
||||
Alert("La entrada de materia prima se ha agregado correctamente");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjCort.RollBack();
|
||||
}
|
||||
ObjCort.Dispose();
|
||||
UPModalCort.Update();
|
||||
|
||||
}
|
||||
}
|
||||
protected void BtnCortEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Valida())
|
||||
{
|
||||
if (TxtModalAdjuntoArchivo.getfiles().Archivos.Count > 0)
|
||||
{
|
||||
Archivo ArchivoAdjunto = TxtModalAdjuntoArchivo.getfiles().Archivos[0];
|
||||
Adjunto = DdlOrdenCorte.SelectedValue + "_" + ArchivoAdjunto.filenameO;
|
||||
}
|
||||
|
||||
ClsCGame ObjCort = new ClsCGame();
|
||||
ObjCort.IniciaTransacSQL();
|
||||
bool Continuar = ObjCort.UpdateCorte(CveCorte, TxtFecha.Text.ToDate(), TxtPeso.Text.ToDouble(), TxtObservacion.Text, Adjunto, TxtTicketBascula.Text, TxtPesoMerma.Text.ToDouble(), DdlMotivo.SelectedValue.ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlOrdenCorte.SelectedValue.ToEntero(), DdlEmpaque.SelectedValue.ToEntero(), DdlFlete.SelectedValue.ToEntero());
|
||||
Continuar = ObjCort.UpdateFleteImporte(DdlOrdenCorte.SelectedValue.ToEntero(), TxtPeso.Text.ToDouble(), DdlFlete.SelectedValue.ToEntero());
|
||||
if (Continuar)
|
||||
{
|
||||
ObjCort.Commit();
|
||||
if (TxtModalAdjuntoArchivo.getfiles().Archivos.Count > 0)
|
||||
{
|
||||
GuardarAdjunto();
|
||||
}
|
||||
this.RegistraScript("$('#DModalCorte').modal('hide');");
|
||||
CargaCorte();
|
||||
Alert("La entrada de materia prima se ha actualizado correctamente");
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjCort.RollBack();
|
||||
}
|
||||
ObjCort.Dispose();
|
||||
UPModalCort.Update();
|
||||
}
|
||||
}
|
||||
|
||||
protected void LnkEliminarCort_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
||||
CveCorte = gvRow.DataKey("CveCorte").ToEntero();
|
||||
ClsCGame ObjCort = new ClsCGame();
|
||||
bool Continuar = ObjCort.RemoveCorte(CveCorte);
|
||||
ObjCort.Dispose();
|
||||
if (Continuar)
|
||||
{
|
||||
CargaCorte();
|
||||
Alert("La entrada de materia prima ha eliminada");
|
||||
}
|
||||
}
|
||||
|
||||
protected void LnkDescargar_Click(object sender, EventArgs e)
|
||||
{
|
||||
string filename = GVCorte.Rows[Index].DataKey("Adjunto").ToString();
|
||||
|
||||
if (!String.IsNullOrEmpty(filename))
|
||||
{
|
||||
String rutaAplicacion = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath);
|
||||
|
||||
String Path = String.Format("{0}\\{1}", UsuarioActual.Empresa.Ruta, "AdjuntosCortes");
|
||||
String ArchivoDestino = String.Format("{0}\\{1}", Path, GVCorte.Rows[Index].DataKey("Adjunto").ToString());
|
||||
System.IO.FileInfo toDownload =
|
||||
new System.IO.FileInfo(ArchivoDestino);
|
||||
if (toDownload.Exists)
|
||||
{
|
||||
Response.ClearContent();
|
||||
Response.ClearHeaders();
|
||||
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
|
||||
Response.ContentType = "application/octet-stream";
|
||||
Response.WriteFile(ArchivoDestino);
|
||||
Response.Flush();
|
||||
Response.Close();
|
||||
Response.End();
|
||||
HttpContext.Current.ApplicationInstance.CompleteRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void BtnAddBitacora_Click(object sender, EventArgs e)
|
||||
{
|
||||
ClsCGame ObjCGame = new ClsCGame();
|
||||
if (ObjCGame.AddBitacora(TxtComentario.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
||||
{
|
||||
Alert("La bitacora fue agregada correctamente");
|
||||
}
|
||||
ObjCGame.Dispose();
|
||||
this.RegistraScript("$('#DModalBitacora').modal('hide');");
|
||||
CargaBitacora();
|
||||
}
|
||||
|
||||
|
||||
protected void LnkPDF_Click(object sender, EventArgs e)
|
||||
{
|
||||
GridViewRow gvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
|
||||
CveCorte = gvRow.DataKey("CveCorte").ToEntero();
|
||||
GeneraPDF();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region AutopostBack
|
||||
|
||||
//protected void DdlClasificacion_SelectedIndexChanged(object sender, EventArgs e)
|
||||
//{
|
||||
// CargaPS();
|
||||
//}
|
||||
|
||||
//protected void DdlTransportista_SelectedIndexChanged(object sender, EventArgs e)
|
||||
//{
|
||||
// CargaChofer();
|
||||
//}
|
||||
|
||||
protected void DdlOrdenCorte_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CargaFletes();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Validacion
|
||||
|
||||
public bool Valida()
|
||||
{
|
||||
if (DdlOrdenCorte.SelectedValue == "-2")
|
||||
{
|
||||
Alert("Tiene que seleccionar una orden de corte", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
return false;
|
||||
}
|
||||
if (DdlMotivo.SelectedValue == "-1")
|
||||
{
|
||||
Alert("Tiene que seleccionar un motivo", ModExtensiones.TipoMensaje.MsgAdvertencia);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GridView
|
||||
|
||||
protected void GvCorte_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
if (e.Row.RowIndex == 0)
|
||||
{
|
||||
e.Row.Cells[0].Text = "Total";
|
||||
e.Row.CssClass = "Totales";
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkButton lb = e.Row.FindControl("LnkPDF") as LinkButton;
|
||||
ScriptManager.GetCurrent(this).RegisterPostBackControl(lb);
|
||||
|
||||
if (e.Row.FCLabel("lblResultadoEmpaque").Text == "")
|
||||
{
|
||||
e.Row.FCLabel("lblResultadoEmpaque").Text = "Sin Asignar";
|
||||
}
|
||||
else
|
||||
{
|
||||
String Css = "Texto";
|
||||
String Liga = $"/CGame/Empaque.aspx?&CveProduccion={e.Row.DataKey("CveProduccion")}";
|
||||
Reference in New Issue
Block a user