Option Strict On Option Explicit On Imports System.Data Imports System.Collections.Generic Imports System.Linq Imports System.Web Imports System.Web.UI.WebControls Imports Extensiones Imports Microsoft.Reporting.WebForms Partial Class CGame_OrdenProduccion Inherits ClsPaginas #Region "PROPIEDADES" Private Property CveOrdenProduccion() As Integer Get Return If(IsNothing(ViewState("CveOrdenProduccion")), -1, CInt(ViewState("CveOrdenProduccion"))) End Get Set ViewState("CveOrdenProduccion") = Value End Set End Property Private Property CveOrdenProduccionDetalle() As Integer Get Return If(IsNothing(ViewState("CveOrdenProduccionDetalle")), -1, CInt(ViewState("CveOrdenProduccionDetalle"))) End Get Set ViewState("CveOrdenProduccionDetalle") = Value End Set End Property Private Property CvePS() As Integer Get Return If(IsNothing(ViewState("CvePS")), -1, CInt(ViewState("CvePS"))) End Get Set ViewState("CvePS") = Value End Set End Property Private Property CveTipoProducto() As Integer Get Return If(IsNothing(ViewState("CveTipoProducto")), -1, CInt(ViewState("CveTipoProducto"))) End Get Set ViewState("CveTipoProducto") = Value End Set End Property Private Property CveTipoMaduracion() As Integer Get Return If(IsNothing(ViewState("CveTipoMaduracion")), -1, CInt(ViewState("CveTipoMaduracion"))) End Get Set ViewState("CveTipoMaduracion") = Value End Set End Property Private Property CveTamaño() As Integer Get Return If(IsNothing(ViewState("CveTamaño")), -1, CInt(ViewState("CveTamaño"))) End Get Set ViewState("CveTamaño") = Value End Set End Property Private Property CveTipoCaja() As Integer Get Return If(IsNothing(ViewState("CveTipoCaja")), -1, CInt(ViewState("CveTipoCaja"))) End Get Set ViewState("CveTipoCaja") = Value End Set End Property Private Property Liquidado() As Integer Get Return If(IsNothing(ViewState("Liquidado")), -1, CInt(ViewState("Liquidado"))) End Get Set ViewState("Liquidado") = Value End Set End Property Private Property XLiquidar() As Integer Get Return If(IsNothing(ViewState("XLiquidar")), -1, CInt(ViewState("XLiquidar"))) End Get Set ViewState("XLiquidar") = Value End Set End Property Private Property Index() As Integer Get Return If(IsNothing(ViewState("Index")), -1, CInt(ViewState("Index"))) End Get Set ViewState("Index") = Value End Set End Property Private Property Opcion() As Integer Get Return If(IsNothing(ViewState("Opcion")), -1, CInt(ViewState("Opcion"))) End Get Set ViewState("Opcion") = Value End Set End Property Private Property Tipo() As Integer Get Return If(IsNothing(ViewState("Tipo")), -1, CInt(ViewState("Tipo"))) End Get Set ViewState("Tipo") = Value End Set End Property Private Property CveVenta() As Integer Get Return If(IsNothing(ViewState("CveVenta")), -1, CInt(ViewState("CveVenta"))) End Get Set ViewState("CveVenta") = Value End Set End Property Private Property CveEstatus() As Integer Get Return If(IsNothing(ViewState("CveEstatus")), -1, CInt(ViewState("CveEstatus"))) End Get Set ViewState("CveEstatus") = Value End Set End Property Private Property Folio() As String Get Return If(IsNothing(ViewState("Folio")), "-1", (ViewState("Folio")).ToString()) End Get Set ViewState("Folio") = Value End Set End Property Private Property FolioRem() As Integer Get Return If(IsNothing(ViewState("FolioRem")), 0, (ViewState("FolioRem")).ToString.ToEntero) End Get Set ViewState("FolioRem") = Value End Set End Property Private Property Modalidad() As String Get Return CType(If(IsNothing(ViewState("Modalidad")), "", (ViewState("Modalidad"))), String) End Get Set ViewState("Modalidad") = Value End Set End Property Private Property ModalidadLiquidacion() As String Get Return CType(If(IsNothing(ViewState("ModalidadLiquidacion")), "", (ViewState("ModalidadLiquidacion"))), String) End Get Set ViewState("ModalidadLiquidacion") = Value End Set End Property Private Property SeCreo() As String Get Return CType(If(IsNothing(ViewState("SeCreo")), "N", (ViewState("SeCreo"))), String) End Get Set ViewState("SeCreo") = Value End Set End Property Private Property DtDetalle As DataTable Get DtDetalle = DirectCast(ViewState("DtDetalle"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtDetalle") = value End Set End Property Private Property DtLiquidacion As DataTable Get DtLiquidacion = DirectCast(ViewState("DtLiquidacion"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtLiquidacion") = value End Set End Property Private Property Dt As DataTable Get Dt = DirectCast(ViewState("Dt"), DataTable) End Get Set(ByVal value As DataTable) ViewState("Dt") = value End Set End Property Private Property EnvioCorreoSurtida() As Boolean Get Return If(IsNothing(ViewState("EnvioCorreoSurtida")), False, CBool((ViewState("EnvioCorreoSurtida")).ToString)) End Get Set ViewState("EnvioCorreoSurtida") = Value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then CveOrdenProduccion = IfNull(Request("CveOrdenProduccion"), "-1").ToString.ToEntero Opcion = IfNull(Request("Opcion"), "-1").ToString.ToEntero CreaDtDetalle() CargaCliente() CargaDatos() CargaTamaño() CargaCalidad() CargaTipoCaja() CargaPS() CargaTipoEmpaque() CargaTipoProducto() End If End Sub #Region "CARGAS" Protected Sub CargaDatos() TxtFechaFlete.Text = Now.AddDays(0).ToShortDateString If CveOrdenProduccion > -1 Then Dim ObjOP As New ClsCGame() If ObjOP.GetOrdenProduccion(CveOrdenProduccion, UsuarioActual.CveEmpresa, -1, "-1", MinFecha, MaxFecha, -1) Then If ObjOP.DtResultados.Rows.Count > 0 Then lblFolio.Text = "OP" + ObjOP.DtResultados(0)("Folio").ToString Folio = ObjOP.DtResultados(0)("Folio").ToString TxtFechaEntrega.Text = ObjOP.DtResultados(0)("FEntrega").ToString DdlCliente.SelectedValue = ObjOP.DtResultados(0)("CveCliente").ToString TxtObservacion.Text = ObjOP.DtResultados(0)("Observaciones").ToString LblEstatus.Text = ObjOP.DtResultados(0)("Estatus").ToString TxtFecha.Text = ObjOP.DtResultados(0)("FechaIng").ToString.ToDateTime.ToShortDateString CveVenta = ObjOP.DtResultados(0)("CveVenta").ToString.ToEntero CveEstatus = ObjOP.DtResultados(0)("CveEstatus").ToString.ToEntero lblNombreUsuario.Text = ObjOP.DtResultados(0)("NombreUsuario").ToString EnvioCorreoSurtida = CBool(ObjOP.DtResultados(0)("EnvioCorreo").ToString.ToEntero) If ObjOP.DtResultados(0)("FechaEmpaqueUSA").ToString.ToDate > MinFecha Then TxtFechaFlete.Text = ObjOP.DtResultados(0)("FechaEmpaqueUSA").ToString.ToDate.ToShortDateString BtnAddFechaFlete.Visible = False TxtFechaFlete.Enabled = False End If TrEstatus.Visible = True BtnCreaPartir.Visible = True BtnClonar.Visible = True If CveEstatus > 3 Then TabEmpaqueUSA.Visible = True End If TabEmpaque.Visible = True LnkEditarMasivo.Visible = True Select Case CveEstatus Case <= 3 LnkEliminarOrdenProduccion.Visible = True Case 4, 5, 6, 7 If CveEstatus = 4 Then LnkSinFletes.Visible = True LnkAbrirOrdenProduccion.Visible = True End Select CargaOPDetalle(ObjOP) CargaCortes(ObjOP) CargaEmpaqueUSA(ObjOP) CargaEmpaque(ObjOP) CargaOPUpdate(ObjOP) CargaTotal() Else Alert("No se encontro la orden de produccion solicitada.", TipoMensaje.MsgAdvertencia) LimpiaPagina() End If End If ObjOP.Dispose() GvEmpaque.DataBind() GvEmpaqueUSAInterno.DataBind() GvEmpaqueUSAExterno.DataBind() GvAvance.DataBind() GvOPUpdate.DataBind() GvFacturacion.DataBind() GvLiquidacion.DataBind() GvCortes.DataBind() GvOP.DataBind() GvGastos.DataBind() UPDatosOrden.Update() UpEmpaqueUSA.Update() UpEmpaque.Update() UpFacturacion.Update() UpMasivo.Update() UpLiquidacion.Update() 'If LtlPorcentajeTotal.Text.ToDouble = 100 And Not EnvioCorreoSurtida Then ' Dim Dt As DataTable ' Dt = Nothing ' 'EnvioCorreo(Dt, CveOrdenProduccion, "SUR") 'End If If TxtFechaFlete.Enabled = False And Not GvEmpaqueUSAExterno.Rows.Count > 0 And Not GvEmpaqueUSAInterno.Rows.Count > 0 Then LnkFletes.Visible = True End If If TabLiquidacion.Visible Then CargaGastos() End If Else LimpiaPagina() End If End Sub Private Sub CargaOPDetalle(ObjCGame As ClsCGame) If ObjCGame.GetOrdenProduccionDetalle(CveOrdenProduccion, UsuarioActual.CveEmpresa) Then DtDetalle = ObjCGame.DtResultados GvOP.DataSource = DtDetalle If DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0 Then Tipo = DtDetalle.Rows(0)("Tipo").ToString.ToEntero If Tipo = 2 Then GvLiquidacion.Columns(6).Visible = True : GvLiquidacion.Columns(7).Visible = True : DivPesoPagado.Visible = True : GvLiquidacionModal.Columns(2).Visible = True : RFVPesoPagado.Enabled = True End If End If End Sub Private Sub CargaCortes(ObjCGame As ClsCGame) If ObjCGame.GetOrdenCorte(UsuarioActual.CveEmpresa, CveOrdenProduccion:=CveOrdenProduccion, Opcion:=2) Then If ObjCGame.DtResultados.Rows.Count > 0 Then TabCortes.Visible = True GvCortes.DataSource = ObjCGame.DtResultados End If End If End Sub Private Sub CargaCliente() Dim ObjOP As New ClsCGame If ObjOP.GetCliente(-1, -1, UsuarioActual.CveEmpresa) Then DdlCliente.DataSource = ObjOP.DtResultados DdlCliente.Items.Insert(0, New ListItem("Seleccione", "-1")) End If ObjOP.Dispose() DdlCliente.DataBind() End Sub Private Sub CargaTamaño() Dim ObjOP As New ClsCGame If ObjOP.GetTamaños(UsuarioActual.CveEmpresa, Estatus:=1) Then DdlTamaño.DataSource = ObjOP.DtResultados DdlTamaño.Items.Insert(0, New ListItem("Seleccione", "-1")) End If ObjOP.Dispose() DdlTamaño.DataBind() End Sub Private Sub CargaCalidad() Dim ObjOP As New ClsCGame If ObjOP.GetCalidad(UsuarioActual.CveEmpresa, Estatus:=1) Then DdlCalidad.DataSource = ObjOP.DtResultados DdlCalidad.Items.Insert(0, New ListItem("Seleccione", "-1")) End If ObjOP.Dispose() DdlCalidad.DataBind() End Sub Private Sub CargaTipoCaja() Dim ObjOP As New ClsCGame If ObjOP.GetTipoCaja(UsuarioActual.CveEmpresa, Estatus:=1) Then DdlTipoCaja.DataSource = ObjOP.DtResultados DdlTipoCaja.Items.Insert(0, New ListItem("Seleccione", "-1")) End If ObjOP.Dispose() DdlTipoCaja.DataBind() End Sub Private Sub CargaPS() Dim ObjCGame As New ClsCGame If ObjCGame.GetPS(UsuarioActual.CveEmpresa) Then DdlPS.DataSource = ObjCGame.DtResultados DdlPS.Items.Insert(0, New ListItem("Seleccione", "-1")) End If ObjCGame.Dispose() DdlPS.DataBind() CargaTipoMaduracion(DdlPS.SelectedValue.ToEntero()) End Sub Private Sub CargaTipoEmpaque() Dim ObjCGame As New ClsCGame If ObjCGame.GetTipoEmpaque(-1, -1, UsuarioActual.CveEmpresa) Then DdlTipoEmpaque.DataSource = ObjCGame.DtResultados DdlTipoEmpaque.Items.Insert(0, New ListItem("Seleccione", "-1")) End If ObjCGame.Dispose() DdlTipoEmpaque.DataBind() End Sub Private Sub CargaTipoProducto() Dim ObjCGame As New ClsCGame If ObjCGame.GetTipoProducto(UsuarioActual.CveEmpresa) Then DdlTipoProducto.DataSource = ObjCGame.DtResultados DdlTipoProducto.Items.Insert(0, New ListItem("Seleccione", "-1")) End If ObjCGame.Dispose() DdlTipoProducto.DataBind() End Sub Private Sub CargaTipoMaduracion(CvePS As Integer) DdlTipoMaduracion.Items.Clear() DdlTipoMaduracion.Items.Insert(0, New ListItem("Seleccione", "-1")) If CvePS <> -1 Then Dim ObjCGame As New ClsCGame If ObjCGame.GetTipoMaduracion(CvePS, -1, -1, UsuarioActual.CveEmpresa) Then DdlTipoMaduracion.DataSource = ObjCGame.DtResultados End If ObjCGame.Dispose() End If DdlTipoMaduracion.DataBind() End Sub Private Sub CargaFolio() Dim ObjFolios As New ClsGralFolios If ObjFolios.GetFolios("OP", UsuarioActual.CveEmpresa) Then If ObjFolios.DtResultados.Rows.Count > 0 Then lblFolio.Text = "OP" + ObjFolios.DtResultados(0)("FActual").ToString Folio = ObjFolios.DtResultados(0)("FActual").ToString Else Alert("Necesita registrar un folio de órden de producción", TipoMensaje.MsgAdvertencia) BtnGuardar.Enabled = False End If End If ObjFolios.Dispose() UPDatosOrden.Update() End Sub Private Sub CargaEmpaqueUSA(ObjCGame As ClsCGame) If ObjCGame.GetFlete(UsuarioActual.CveEmpresa, Tipo:=2, TipoFlete:=1) Then GvEmpaqueUSAInterno.DataSource = ObjCGame.DtResultados.FiltraParametros(String.Format("CveOrdenProduccion = {0}", CveOrdenProduccion)) End If If ObjCGame.GetFlete(UsuarioActual.CveEmpresa, Tipo:=2, TipoFlete:=2) Then GvEmpaqueUSAExterno.DataSource = ObjCGame.DtResultados.FiltraParametros(String.Format("CveOrdenProduccion = {0}", CveOrdenProduccion)) End If End Sub Private Sub CargaEmpaque(ObjCGame As ClsCGame) Dim TotSolicitado, TotAvance As Double If ObjCGame.GetProduccionResultado(-1, CveOrdenProduccion:=CveOrdenProduccion, CveEmpresa:=UsuarioActual.CveEmpresa) Then GvEmpaque.DataSource = ObjCGame.DtResultados.FiltraParametros(String.Format("CveOrdenProduccion = {0}", CveOrdenProduccion)) If ObjCGame.DtResultados.Rows.Count > 0 Then TabAvance.Visible = True DivPorcentaje.Visible = True If ObjCGame.GetAvance(CveOrdenProduccion, UsuarioActual.CveEmpresa) Then GvAvance.DataSource = ObjCGame.DtResultados GvFacturacion.DataSource = ObjCGame.DtResultados For Each Row As DataRow In ObjCGame.DtResultados.Rows TotSolicitado = TotSolicitado + Row("Cantidad").ToString().ToDouble() TotAvance = TotAvance + Row("Avance").ToString().ToDouble() Next End If If ObjCGame.DtResultados.Rows.Count > 0 Then CargaAvance(ObjCGame, TotAvance, TotSolicitado) If Opcion > 0 Then Tab.ActiveTabIndex = 3 End If End If End If If CveEstatus > 5 Then TabFacturacion.Visible = True TabLiquidacion.Visible = True If ObjCGame.GetOrdenProduccionDetalleLiquidacion(UsuarioActual.CveEmpresa, CveOrdenProduccion) Then GvLiquidacion.DataSource = ObjCGame.DtResultados End If If ObjCGame.GetCargoFijoCliente(DdlCliente.SelectedValue.ToEntero) Then GvGastos.DataSource = ObjCGame.DtResultados End If End If End If If CveVenta > 0 Then BtnRemisionar.Visible = False BtnIrRemision.Visible = True HplFacturar.Visible = True HplFacturar.NavigateUrl = $"/Ventas/Ventas.aspx?CveOrdenProduccion={CveOrdenProduccion}&CveCliente=240546&TipoDocto=Ing" End If End Sub Public Sub CargaAvance(ObjCGame As ClsCGame, TotAvance As Double, TotSolicitado As Double) LtlPorcentajeTotal.Text = ((TotAvance * 100) / TotSolicitado).FormatoNumero() If LtlPorcentajeTotal.Text.ToString().ToDouble() <= 33 Then LtlPorcentajeTotal.ForeColor = Drawing.Color.Red LblPor.ForeColor = Drawing.Color.Red End If If LtlPorcentajeTotal.Text.ToString().ToDouble() > 33 And LtlPorcentajeTotal.Text.ToString().ToDouble() <= 66 Then LtlPorcentajeTotal.ForeColor = Drawing.Color.Yellow LblPor.ForeColor = Drawing.Color.Yellow End If If LtlPorcentajeTotal.Text.ToString().ToDouble() > 66 Then LtlPorcentajeTotal.ForeColor = Drawing.Color.Green LblPor.ForeColor = Drawing.Color.Green End If UpEstatus.Update() End Sub Protected Sub CargaTotal() If SeCreo = "N" Then Dim drNuevo = DtDetalle.NewRow For Each dt As DataRow In DtDetalle.Rows If dt("Cantidad").ToString.ToEntero > 0 Then drNuevo("Cantidad") = drNuevo("Cantidad").ToString.ToEntero + dt("Cantidad").ToString.ToEntero End If Next DtDetalle.Rows.InsertAt(drNuevo, 0) SeCreo = "S" Else Dim Cantidad As Integer = 0 For Each dt As DataRow In DtDetalle.Rows If dt("Cantidad").ToString.ToEntero > 0 And dt("CvePS").ToString() <> "" Then Cantidad = Cantidad + dt("Cantidad").ToString.ToEntero End If Next DtDetalle.Rows(0)("Cantidad") = Cantidad DtDetalle.AcceptChanges() End If End Sub Protected Sub CargaOPUpdate(ObjCGame As ClsCGame) If ObjCGame.GetOrdenProduccion(-1, UsuarioActual.CveEmpresa, 1, "-1", MinFecha, MaxFecha, -1) Then GvOPUpdate.DataSource = ObjCGame.DtResultados End If End Sub #End Region #Region "DTDETALLE" Private Sub CreaDtDetalle() DtDetalle = New DataTable DtDetalle.Columns.Add("CveOrdenProduccionDetalle", GetType(Integer)) DtDetalle.Columns.Add("Cantidad", GetType(Integer)) DtDetalle.Columns.Add("CvePS", GetType(Integer)) DtDetalle.Columns.Add("CveTamaño", GetType(Integer)) DtDetalle.Columns.Add("CveTipoEtiqueta", GetType(Boolean)) DtDetalle.Columns.Add("CveCalidad", GetType(Integer)) DtDetalle.Columns.Add("CveTipoCaja", GetType(Integer)) DtDetalle.Columns.Add("Observaciones", GetType(String)) DtDetalle.Columns.Add("PS", GetType(String)) DtDetalle.Columns.Add("Tamaño", GetType(String)) DtDetalle.Columns.Add("TipoEmpaque", GetType(String)) DtDetalle.Columns.Add("TipoProducto", GetType(String)) DtDetalle.Columns.Add("TipoMaduracion", GetType(String)) DtDetalle.Columns.Add("Calidad", GetType(String)) DtDetalle.Columns.Add("TipoCaja", GetType(String)) DtDetalle.Columns.Add("PU", GetType(Double)) DtDetalle.Columns.Add("Instrucciones", GetType(String)) DtDetalle.Columns.Add("CveTipoEmpaque", GetType(Integer)) DtDetalle.Columns.Add("CveTipoProducto", GetType(Integer)) DtDetalle.Columns.Add("CveTipoMaduracion", GetType(Integer)) End Sub Private Sub AddDtDetalle(Cantidad As Integer, CvePS As Integer, CveTamaño As Integer, CveTipoEtiqueta As Boolean, CveCalidad As Integer, CveTipoCaja As Integer, Observaciones As String, TipoEmpaque As String, PS As String, Tamaño As String, Calidad As String, TipoCaja As String, PU As Double, Instrucciones As String, CveTipoEmpaque As Integer, CveTipoProducto As Integer, CveTipoMaduracion As Integer, TipoProducto As String, TipoMaduracion As String) Dim Row As DataRow = Nothing DtDetalle.AcceptChanges() Row = DtDetalle.NewRow Row("CveOrdenProduccionDetalle") = -1 Row("Cantidad") = Cantidad Row("CvePS") = CvePS Row("CveTamaño") = CveTamaño Row("CveTipoEtiqueta") = CveTipoEtiqueta Row("CveCalidad") = CveCalidad Row("CveTipoCaja") = CveTipoCaja Row("Observaciones") = Observaciones Row("TipoEmpaque") = TipoEmpaque Row("PS") = PS Row("Tamaño") = Tamaño Row("Calidad") = Calidad Row("TipoCaja") = TipoCaja Row("PU") = PU Row("CveTipoEmpaque") = CveTipoEmpaque Row("CveTipoProducto") = CveTipoProducto Row("CveTipoMaduracion") = CveTipoMaduracion Row("TipoProducto") = TipoProducto Row("TipoMaduracion") = TipoMaduracion Row("Instrucciones") = Instrucciones DtDetalle.Rows.Add(Row) DtDetalle.AcceptChanges() End Sub Private Sub UpdateDtDetalle(Cantidad As Integer, CvePS As Integer, CveTamaño As Integer, CveTipoEtiqueta As Boolean, CveCalidad As Integer, CveTipoCaja As Integer, Observaciones As String, TipoEmpaque As String, PS As String, Tamaño As String, Calidad As String, TipoCaja As String, PU As Double, Instrucciones As String, CveTipoEmpaque As Integer, CveTipoProducto As Integer, CveTipoMaduracion As Integer, TipoProducto As String, TipoMaduracion As String) DtDetalle.AcceptChanges() DtDetalle.Rows(Index)("Cantidad") = Cantidad DtDetalle.Rows(Index)("CvePS") = CvePS DtDetalle.Rows(Index)("CveTamaño") = CveTamaño DtDetalle.Rows(Index)("CveTipoEtiqueta") = CveTipoEtiqueta DtDetalle.Rows(Index)("CveCalidad") = CveCalidad DtDetalle.Rows(Index)("CveTipoCaja") = CveTipoCaja DtDetalle.Rows(Index)("Observaciones") = Observaciones DtDetalle.Rows(Index)("TipoEmpaque") = TipoEmpaque DtDetalle.Rows(Index)("PS") = PS DtDetalle.Rows(Index)("Tamaño") = Tamaño DtDetalle.Rows(Index)("Calidad") = Calidad DtDetalle.Rows(Index)("TipoCaja") = TipoCaja DtDetalle.Rows(Index)("PU") = PU DtDetalle.Rows(Index)("Instrucciones") = Instrucciones DtDetalle.Rows(Index)("CveTipoProducto") = CveTipoProducto DtDetalle.Rows(Index)("CveTipoProducto") = CveTipoProducto DtDetalle.Rows(Index)("CveTipoMaduracion") = CveTipoMaduracion DtDetalle.Rows(Index)("TipoProducto") = TipoProducto DtDetalle.Rows(Index)("TipoMaduracion") = TipoMaduracion DtDetalle.Rows(Index)("CveTipoEmpaque") = CveTipoEmpaque DtDetalle.AcceptChanges() End Sub #End Region #Region "BTN'S" Protected Sub LnkEditarTipo_Click(sender As Object, e As EventArgs) LimpiaModal() Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) CveOrdenProduccionDetalle = gvRow.DataKey("CveOrdenProduccionDetalle").ToEntero() TxtCantidad.Text = gvRow.DataKey("Cantidad") TxtPrecio.Text = gvRow.DataKey("PU") TxtInstrucciones.Text = gvRow.DataKey("Instrucciones") TxtObservaciones.Text = gvRow.DataKey("Observaciones") DdlTamaño.SelectedValueExist(gvRow.DataKey("CveTamaño")) DdlCalidad.SelectedValueExist(gvRow.DataKey("CveCalidad")) DdlTipoCaja.SelectedValueExist(gvRow.DataKey("CveTipoCaja")) ChkTipoEtiqueta.Checked = CBool((gvRow.DataKey("CveTipoEtiqueta"))) DdlPS.SelectedValueExist(gvRow.DataKey("CvePS")) CargaTipoMaduracion(DdlPS.SelectedValue.ToEntero()) DdlTipoMaduracion.SelectedValueExist(gvRow.DataKey("CveTipoMaduracion")) DdlTipoProducto.SelectedValueExist(gvRow.DataKey("CveTipoProducto")) DdlTipoEmpaque.SelectedValueExist(gvRow.DataKey("CveTipoEmpaque")) Index = gvRow.RowIndex RegistraScript("$('#DivOP').modal()") BtnOPADD.Text = "Actualizar" Modalidad = "U" GvOP.DataSource = DtDetalle GvOP.DataBind() UpDatos.Update() UPModalAdd.Update() End Sub Protected Sub LnkAgregarConcepto_Click(sender As Object, e As EventArgs) RegistraScript("$('#DivOP').modal()") LimpiaModal() BtnOPADD.Text = "Agregar" Modalidad = "A" GvOP.DataSource = DtDetalle GvOP.DataBind() UpDatos.Update() End Sub Protected Sub BtnOPADD_Click(sender As Object, e As EventArgs) If Valida() Then If Modalidad = "A" Then AddDtDetalle(TxtCantidad.Text.ToEntero, DdlPS.SelectedValue.ToEntero, DdlTamaño.SelectedValue.ToEntero, ChkTipoEtiqueta.Checked, DdlCalidad.SelectedValue.ToEntero, DdlTipoCaja.SelectedValue.ToEntero, TxtObservaciones.Text, DdlTipoEmpaque.SelectedItem.Text, DdlPS.SelectedItem.Text, DdlTamaño.SelectedItem.Text, DdlCalidad.SelectedItem.Text, DdlTipoCaja.SelectedItem.Text, TxtPrecio.Text.ToDouble, TxtInstrucciones.Text, DdlTipoEmpaque.SelectedValue.ToEntero(), DdlTipoProducto.SelectedValue.ToEntero(), DdlTipoMaduracion.SelectedValue.ToEntero(), DdlTipoProducto.SelectedItem.Text, DdlTipoMaduracion.SelectedItem.Text) ElseIf Modalidad = "U" Then UpdateDtDetalle(TxtCantidad.Text.ToEntero, DdlPS.SelectedValue.ToEntero, DdlTamaño.SelectedValue.ToEntero, ChkTipoEtiqueta.Checked, DdlCalidad.SelectedValue.ToEntero, DdlTipoCaja.SelectedValue.ToEntero, TxtObservaciones.Text, DdlTipoEmpaque.SelectedItem.Text, DdlPS.SelectedItem.Text, DdlTamaño.SelectedItem.Text, DdlCalidad.SelectedItem.Text, DdlTipoCaja.SelectedItem.Text, TxtPrecio.Text.ToDouble, TxtInstrucciones.Text, DdlTipoEmpaque.SelectedValue.ToEntero(), DdlTipoProducto.SelectedValue.ToEntero(), DdlTipoMaduracion.SelectedValue.ToEntero(), DdlTipoProducto.SelectedItem.Text, DdlTipoMaduracion.SelectedItem.Text) End If CargaTotal() RegistraScript("$('#DivOP').modal('hide')") GvOP.DataSource = DtDetalle GvOP.DataBind() UpDatos.Update() End If End Sub Protected Sub LnkEliminarTipo_Click(sender As Object, e As EventArgs) Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) DtDetalle.AcceptChanges() DtDetalle.Rows(gvRow.RowIndex)("Cantidad") = -1 DtDetalle.AcceptChanges() If DtDetalle.Rows(gvRow.RowIndex)("CveOrdenProduccionDetalle").ToString.ToEntero = -1 Then DtDetalle.AcceptChanges() DtDetalle.Rows(gvRow.RowIndex).Delete() DtDetalle.AcceptChanges() End If CargaTotal() GvOP.DataSource = DtDetalle GvOP.DataBind() If Not GvOP.Rows.Count > 0 Then LimpiaGvOPShowHeader() End If UpDatos.Update() End Sub Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click If DdlCliente.SelectedValue = "-1" Then Alert("Tiene que seleccionar un cliente", TipoMensaje.MsgAdvertencia) Exit Sub End If If Not DtDetalle.Rows.Count > 0 Then Alert("Se tiene que agregar como mínimo un producto", TipoMensaje.MsgAdvertencia) Exit Sub End If Dim ErrorGuardar As Boolean = False Dim ObjOP As New ClsCGame Dim _CveOrdenProduccion As Integer Dim _Folio = "" ObjOP.IniciaTransacSQL() If CveOrdenProduccion > -1 Then If ObjOP.UpdateOrdenProduccion(CveOrdenProduccion, Folio, DdlCliente.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, TxtObservacion.Text, CveEstatus, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then _CveOrdenProduccion = CveOrdenProduccion Else ErrorGuardar = True End If Else If ObjOP.AddOrdenProduccion(Folio, DdlCliente.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, TxtObservacion.Text, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then _CveOrdenProduccion = ObjOP.CveOrdenProduccion If ObjOP.GetOrdenProduccion(_CveOrdenProduccion, UsuarioActual.CveEmpresa, -1, "-1", MinFecha, MaxFecha, -1) Then _Folio = ObjOP.DtResultados(0)("Folio").ToString End If Else ErrorGuardar = True End If End If If ErrorGuardar = False Then For Each dt As DataRow In DtDetalle.Rows If dt("CveOrdenProduccionDetalle").ToString.ToEntero = -1 And Not dt("CvePS").ToString = "" Then If Not ObjOP.AddOrdenProduccionDetalle(_CveOrdenProduccion, dt("Cantidad").ToString.ToEntero, dt("CvePS").ToString.ToEntero, dt("CveTamaño").ToString.ToEntero, CBool(dt("CveTipoEtiqueta")), dt("CveCalidad").ToString.ToEntero, dt("CveTipoCaja").ToString.ToEntero, dt("Observaciones").ToString, dt("PU").ToString.ToDouble, dt("Instrucciones").ToString, dt("CveTipoProducto").ToString.ToEntero, dt("CveTipoEmpaque").ToString.ToEntero, dt("CveTipoMaduracion").ToString.ToEntero) Then ErrorGuardar = True Exit For End If ElseIf dt("Cantidad").ToString.ToEntero = -1 And Not dt("CvePS").ToString = "" Then If Not ObjOP.RemoveOrdenProduccionDetalle(dt("CveOrdenProduccionDetalle").ToString.ToEntero) Then ErrorGuardar = True Exit For End If ElseIf dt("CvePS").ToString <> "" Then If Not ObjOP.UpdateOrdenProduccionDetalle(dt("CveOrdenProduccionDetalle").ToString.ToEntero, CveOrdenProduccion, dt("Cantidad").ToString.ToEntero, dt("CvePS").ToString.ToEntero, dt("CveTamaño").ToString.ToEntero, CBool(dt("CveTipoEtiqueta")), dt("CveCalidad").ToString.ToEntero, dt("CveTipoCaja").ToString.ToEntero, dt("Observaciones").ToString, dt("PU").ToString.ToDouble, dt("Instrucciones").ToString, dt("CveTipoProducto").ToString.ToEntero, dt("CveTipoEmpaque").ToString.ToEntero, dt("CveTipoMaduracion").ToString.ToEntero) Then ErrorGuardar = True Exit For End If End If Next End If If ErrorGuardar = False And _CveOrdenProduccion > 0 Then ObjOP.Commit() If Not CveOrdenProduccion > 0 Then Alert($"Guardado Correctamente con el folio: {_Folio}.", TipoMensaje.MsgInformacion, $"document.location.href=""/CGame/OrdenProduccion.aspx?CveOrdenProduccion={_CveOrdenProduccion}""") Folio = _Folio Dim Dt As DataTable Dt = Nothing 'EnvioCorreo(Dt, _CveOrdenProduccion, "OP") Else Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion) End If Else ObjOP.RollBack() End If End Sub Private Sub LnkEliminarOrdenProduccion_Click(sender As Object, e As EventArgs) Handles LnkEliminarOrdenProduccion.Click Dim ObjOP As New ClsCGame If ObjOP.UpdateOrdenProduccionEstatus(CveOrdenProduccion, 4) Then Alert("La orden de producción fue cerrada correctamente", TipoMensaje.MsgInformacion, $"document.location.href=""/CGame/OrdenProduccion.aspx?CveOrdenProduccion={CveOrdenProduccion}""") LblEstatus.Text = "Empacada" Dim Dt As DataTable Dt = Nothing End If ObjOP.Dispose() UpEstatus.Update() UpTabs.Update() 'EnvioCorreo(Dt, CveOrdenProduccion, "SUR") End Sub Protected Sub LnkSinFletes_Click(sender As Object, e As EventArgs) Dim ObjOP As New ClsCGame If ObjOP.UpdateOrdenProduccionEstatus(CveOrdenProduccion, 6) Then Alert("La orden de producción fue cerrada correctamente sin flete.", TipoMensaje.MsgInformacion, $"document.location.href=""/CGame/OrdenProduccion.aspx?CveOrdenProduccion={CveOrdenProduccion}""") LblEstatus.Text = "Flete Empaque-USA en camino" End If ObjOP.Dispose() UpEstatus.Update() UpTabs.Update() End Sub Protected Sub LnkAbrirOrdenProduccion_Click(sender As Object, e As EventArgs) Dim ObjOP As New ClsCGame If ObjOP.UpdateOrdenProduccionEstatus(CveOrdenProduccion, 3) Then Alert("La orden de producción fue abierta correctamente.", TipoMensaje.MsgInformacion, $"document.location.href=""/CGame/OrdenProduccion.aspx?CveOrdenProduccion={CveOrdenProduccion}""") LblEstatus.Text = "Asignada" End If ObjOP.Dispose() UpEstatus.Update() UpTabs.Update() End Sub Protected Sub BtnAddFechaFlete_Click(sender As Object, e As EventArgs) Dim ObjCGame As New ClsCGame() If (ObjCGame.UpdateOrdenProduccionFechaEmpaqueUSA(CveOrdenProduccion, TxtFechaFlete.Text.ToDate())) Then Dim Dt As DataTable Dt = Nothing EnvioCorreo(Dt, CveOrdenProduccion, "UpFlete") Alert("La fecha del flete se asigno correctamente", TipoMensaje.MsgInformacion, $"document.location.href=""/CGame/OrdenProduccion.aspx?CveOrdenProduccion={CveOrdenProduccion}""") End If ObjCGame.Dispose() UpEmpaqueUSA.Update() UpAcciones.Update() End Sub Protected Sub BtnRemisionar_Click(sender As Object, e As EventArgs) Response.Redirect("/Ventas/Ventas.aspx?CveOrdenProduccion=" + CveOrdenProduccion.ToString() + "&CveCliente=240546", True) UpFacturacion.Update() End Sub Protected Sub BtnIrRemision_Click(sender As Object, e As EventArgs) Response.Redirect("/Ventas/Ventas.aspx?CveVenta=" + CveVenta.ToString(), True) UpFacturacion.Update() End Sub Protected Sub LnkClonar_Click(sender As Object, e As EventArgs) Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) AddDtDetalle(gvRow.DataKey("Cantidad").ToString().ToEntero(), gvRow.DataKey("CvePS").ToString().ToEntero(), gvRow.DataKey("CveTamaño").ToString().ToEntero(), Convert.ToBoolean(gvRow.DataKey("CveTipoEtiqueta")), gvRow.DataKey("CveCalidad").ToString().ToEntero(), gvRow.DataKey("CveTipoCaja").ToString().ToEntero(), gvRow.DataKey("Observaciones").ToString(), gvRow.DataKey("TipoEmpaque").ToString(), gvRow.DataKey("PS").ToString(), gvRow.DataKey("Tamaño").ToString(), gvRow.DataKey("Calidad").ToString(), gvRow.DataKey("TipoCaja").ToString(), gvRow.DataKey("PU").ToString().ToDouble(), gvRow.DataKey("Instrucciones").ToString(), gvRow.DataKey("CveTipoEmpaque").ToString().ToEntero(), gvRow.DataKey("CveTipoProducto").ToString().ToEntero(), gvRow.DataKey("CveTipoMaduracion").ToString().ToEntero(), gvRow.DataKey("TipoProducto").ToString(), gvRow.DataKey("TipoMaduracion").ToString()) GvOP.DataSource = DtDetalle GvOP.DataBind() UpDatos.Update() End Sub Protected Sub BtnAddClonar_Click(sender As Object, e As EventArgs) Dim Index As Integer Dim ErrorGuardar As Boolean = False Dim ObjOP As New ClsCGame Dt = New DataTable Dt.Columns.Add("CveOrdenProduccion", GetType(Integer)) Dt.Columns.Add("Folio", GetType(String)) Dim R As DataRow = Nothing R = Dt.NewRow R("CveOrdenProduccion") = CveOrdenProduccion R("Folio") = Folio Dt.Rows.Add(R) Dt.AcceptChanges() For Index = 1 To TxtNumClonar.Text.ToEntero Dim _CveOrdenProduccion As Integer Dim _Folio = "" ObjOP.IniciaTransacSQL() If ObjOP.AddOrdenProduccion(Folio, DdlCliente.SelectedValue.ToEntero, TxtFechaEntrega.Text.ToDate, TxtObservacion.Text, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then _CveOrdenProduccion = ObjOP.CveOrdenProduccion If ObjOP.GetOrdenProduccion(_CveOrdenProduccion, UsuarioActual.CveEmpresa, -1, "-1", MinFecha, MaxFecha, -1) Then _Folio = ObjOP.DtResultados(0)("Folio").ToString End If Else ErrorGuardar = True End If If ErrorGuardar = False Then For Each dr As DataRow In DtDetalle.Rows If dr("Cantidad").ToString.ToEntero > 0 And dr("CvePS").ToString <> "" Then If Not ObjOP.AddOrdenProduccionDetalle(_CveOrdenProduccion, dr("Cantidad").ToString.ToEntero, dr("CvePS").ToString.ToEntero, dr("CveTamaño").ToString.ToEntero, CBool(dr("CveTipoEtiqueta")), dr("CveCalidad").ToString.ToEntero, dr("CveTipoCaja").ToString.ToEntero, dr("Observaciones").ToString, dr("PU").ToString.ToDouble, dr("Instrucciones").ToString, dr("CveTipoProducto").ToString.ToEntero, dr("CveTipoEmpaque").ToString.ToEntero, dr("CveTipoMaduracion").ToString.ToEntero) Then ErrorGuardar = True Exit For End If End If Next End If Dim Row As DataRow = Nothing Row = Dt.NewRow Row("CveOrdenProduccion") = _CveOrdenProduccion Row("Folio") = _Folio Dt.Rows.Add(Row) Dt.AcceptChanges() Next If Not ErrorGuardar Then ObjOP.Commit() Alert("La orden de producción ha sido clonada correctamente.", TipoMensaje.MsgInformacion, $"document.location.href=""/CGame/RepOrdenProduccion.aspx?Opcion=1""") 'EnvioCorreo(Dt, -1, "OP") Else ObjOP.RollBack() End If ObjOP.Dispose() End Sub Protected Sub BtnClonar_Click(sender As Object, e As EventArgs) RegistraScript("$('#DivClonar').modal()") UpModalClonar.Update() End Sub Protected Sub BtnFechaUpdate_Click(sender As Object, e As EventArgs) Dim ObjCGame As New ClsCGame ObjCGame.IniciaTransacSQL() Dim ErrorTrans = False Dim Selecciono = False For Each Gv As GridViewRow In GvOPUpdate.Rows If Gv.FCCheckBox("ChkUpdate").Checked = True Then Selecciono = True If Not ObjCGame.UpdateOrdenProduccion(Gv.DataKey("CveOrdenProduccion").ToEntero, Gv.DataKey("Folio"), Gv.DataKey("CveCliente").ToEntero, TxtFechaUpdate.Text.ToDate(), Gv.DataKey("Observaciones"), Gv.DataKey("CveEstatus").ToEntero(), Gv.DataKey("CveUsuario").ToEntero, UsuarioActual.CveEmpresa) Then ErrorTrans = True End If End If Next If Not ErrorTrans Then ObjCGame.Commit() If Not Selecciono Then Alert("Tiene que seleccionar al menos una orden de produccion", TipoMensaje.MsgAdvertencia) Else Alert("Las fechas se editaron correctamente", TipoMensaje.MsgInformacion, $"document.location.href=""/CGame/OrdenProduccion.aspx?CveOrdenProduccion={CveOrdenProduccion}""") RegistraScript("$('#DivUpdateMasivo').modal('hide')") End If Else ObjCGame.RollBack() End If ObjCGame.Dispose() End Sub Protected Sub LnkEditarMasivo_Click(sender As Object, e As EventArgs) RegistraScript("$('#DivUpdateMasivo').modal()") TxtFechaUpdate.Text = Now.ToShortDateString() UpMasivo.Update() End Sub Protected Sub LnkDesasignarFruta_Click(sender As Object, e As EventArgs) Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) Dim ObjCGame As New ClsCGame() If ObjCGame.DesasignarProduccionResultado(gvRow.DataKey("CveProduccionResultado").ToEntero, CveOrdenProduccion) Then Alert("La fruta se desasigno correctamente", TipoMensaje.MsgInformacion, $"document.location.href=""/CGame/OrdenProduccion.aspx?CveOrdenProduccion={CveOrdenProduccion}""") End If ObjCGame.Dispose() End Sub #End Region #Region "VALIDACIONES" Public Function Valida() As Boolean If DdlTipoEmpaque.SelectedValue = "-1" Then Alert("Tiene que seleccionar una tipo de empaque", TipoMensaje.MsgAdvertencia) Return False End If If DdlTipoProducto.SelectedValue = "-1" Then Alert("Tiene que seleccionar una tipo de producto", TipoMensaje.MsgAdvertencia) Return False End If If DdlTipoMaduracion.SelectedValue = "-1" Then Alert("Tiene que seleccionar una tipo de maduración", TipoMensaje.MsgAdvertencia) Return False End If If DdlPS.SelectedValue = "-1" Then Alert("Tiene que seleccionar un producto", TipoMensaje.MsgAdvertencia) Return False End If If DdlTamaño.SelectedValue = "-1" Then Alert("Tiene que seleccionar un Tamaño", TipoMensaje.MsgAdvertencia) Return False End If 'If DdlTipoEtiqueta.SelectedValue = "-1" Then ' Alert("Tiene que seleccionar un tipo de etiqueta", TipoMensaje.MsgAdvertencia) ' Return False 'End If If DdlCalidad.SelectedValue = "-1" Then Alert("Tiene que seleccionar una calidad", TipoMensaje.MsgAdvertencia) Return False End If If DdlTipoCaja.SelectedValue = "-1" Then Alert("Tiene que seleccionar un tipo de caja", TipoMensaje.MsgAdvertencia) Return False End If 'If DdlClasificacion.SelectedValue = "-1" Then ' Alert("Tiene que seleccionar una clasificacion", TipoMensaje.MsgAdvertencia) ' Return False 'End If Return True End Function #End Region #Region "LIMPIA" Protected Sub LimpiaPagina() lblNombreUsuario.Text = UsuarioActual.Nombre TxtFecha.Text = Now.AddDays(0).ToShortDateString TxtFechaEntrega.Text = Now.AddDays(0).ToShortDateString TxtObservacion.Text = "" DdlCliente.SelectedValue = "-1" UPDatosOrden.Update() UpEstatus.Update() LimpiaGvOPShowHeader() CargaFolio() DtDetalle.Clear() End Sub Protected Sub LimpiaModal() TxtCantidad.Text = "" TxtPrecio.Text = "" TxtInstrucciones.Text = "" TxtObservaciones.Text = "" ChkTipoEtiqueta.Checked = False DdlPS.SelectedValue = "-1" CargaTipoMaduracion(DdlPS.SelectedValue.ToEntero()) DdlTipoEmpaque.SelectedValue = "-1" DdlTipoProducto.SelectedValue = "-1" DdlTamaño.SelectedValue = "-1" DdlTipoCaja.SelectedValue = "-1" DdlCalidad.SelectedValue = "-1" UPModalAdd.Update() End Sub Protected Sub LimpiaGvOPShowHeader() Dim Dt = New DataSet Dt.Tables.Add("Datos") Dt.Tables("Datos").Columns.Add("") GvOP.DataSource = Dt.Tables("Datos") GvOP.DataBind() UpDatos.Update() End Sub #End Region #Region "SELECT INDEX CHANGE" 'Private Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClasificacion.SelectedIndexChanged ' CargaPS() 'End Sub 'Private Sub DdlPS_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPS.SelectedIndexChanged ' CargaUM() 'End Sub Protected Sub DdlPS_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPS.SelectedIndexChanged CargaTipoMaduracion(DdlPS.SelectedValue.ToEntero) End Sub #End Region #Region "GRIDVIEW" Protected Sub GvAvance_RowDataBound(sender As Object, e As GridViewRowEventArgs) If (e.Row.RowType = DataControlRowType.DataRow) Then e.Row.Cells(11).Text = e.Row.Cells(11).Text.FormatoNumero() + "%" e.Row.Cells(10).Text = e.Row.Cells(10).Text.FormatoNumero() e.Row.Cells(9).Text = e.Row.Cells(9).Text.FormatoNumero() e.Row.Cells(9).Text = e.Row.Cells(8).Text.FormatoNumero() If e.Row.DBCampo("PorcentajeAvance").ToString().ToDouble() <= 33 Then e.Row.Cells(12).BackColor = Drawing.Color.Red End If If e.Row.DBCampo("PorcentajeAvance").ToString().ToDouble() > 33 And e.Row.DBCampo("PorcentajeAvance").ToString().ToDouble() <= 66 Then e.Row.Cells(12).BackColor = Drawing.Color.Yellow End If If e.Row.DBCampo("PorcentajeAvance").ToString().ToDouble() > 66 Then e.Row.Cells(12).BackColor = Drawing.Color.Green End If If e.Row.DataKey("CveTipoEtiqueta").ToEntero() = 1 Then e.Row.FCLabel("LblTipoEtiqueta").Text = "Si" Else e.Row.FCLabel("LblTipoEtiqueta").Text = "No" End If End If End Sub Protected Sub GvEmpaque_RowDataBound(sender As Object, e As GridViewRowEventArgs) If (e.Row.RowType = DataControlRowType.DataRow) Then Dim Css = "Texto" Dim Liga = $"/CGame/Empaque.aspx?&CveProduccion={e.Row.DataKey("CveProduccion")}" e.Row.FCLabel("LblFolio").Text = "" + e.Row.FCLabel("LblFolio").Text + "" If e.Row.DataKey("CveTipoEtiqueta").ToEntero() = 1 Then e.Row.FCLabel("LblTipoEtiqueta").Text = "Si" Else e.Row.FCLabel("LblTipoEtiqueta").Text = "No" End If End If End Sub Private Sub GvOP_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvOP.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("Cantidad").ToEntero() = -1 Then e.Row.Visible = False End If If e.Row.RowIndex = 0 Then e.Row.CssClass = "Totales" e.Row.Cells(11).Text = "" End If If e.Row.DataKey("CveTipoEtiqueta").ToEntero = 1 Then e.Row.FCLabel("LblTipoEtiqueta").Text = "Si" ElseIf e.Row.RowIndex > 0 Then e.Row.FCLabel("LblTipoEtiqueta").Text = "No" End If End If End Sub Protected Sub GvEmpaqueUSAInterno_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then If CBool(e.Row.DBCampo("ConCruce")) = True Then e.Row.FCLabel("LblConcruce").Text = "Si" Else e.Row.FCLabel("LblConcruce").Text = "No" End If End If End Sub 'Protected Sub GvOrdenCorte_RowDataBound(sender As Object, e As GridViewRowEventArgs) ' If e.Row.RowType = DataControlRowType.DataRow Then ' If CveOrdenProduccion > 0 Then ' e.Row.FCTextBox("TxtFechaCorte").Text = Date.Now.ToShortDateString() ' Dim ObjCGame As New ClsCGame ' If ObjCGame.GetHuerta(UsuarioActual.CveEmpresa) Then ' e.Row.FCDropDownList("DdlHuerta").DataSource = ObjCGame.DtResultados ' e.Row.FCDropDownList("DdlHuerta").Items.Insert(0, New ListItem("Seleccione", "-1")) ' e.Row.FCDropDownList("DdlHuerta").DataBind() ' End If ' ObjCGame.Dispose() ' e.Row.FCLinkButton("BtnDividir").Attributes.Add("onclick", String.Format("Dividir('{0}');", e.Row.FCTextBox("TxtCantDividir").ClientID)) ' e.Row.FCLinkButton("BtnDividir").CommandArgument = e.Row.RowIndex.ToString() ' e.Row.FCTextBox("TxtCantDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("Cantidad"), e.Row.FCLinkButton("BtnDividir").ClientID)) ' End If ' End If 'End Sub Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) If (e.Row.RowType = DataControlRowType.DataRow) Then Dim Css = "Texto" Dim Liga = $"/CGame/RepOrdenCorteDetalle.aspx?&CveOrdenCorte={e.Row.DataKey("CveOrdenCorte")}" e.Row.FCLabel("LblFolioOC").Text = "" + e.Row.FCLabel("LblFolioOC").Text + "" If Not e.Row.DBCampo("FechaFleteHuertaEmpaque").ToString.ToDate() > MinFecha Then e.Row.Cells(8).Text = "No Asignada" End If Dim ObjCGame As New ClsCGame If ObjCGame.GetCorteResumen(e.Row.DBCampo("CveOrdenCorte").ToEntero()) Then If ObjCGame.DtResultados.Rows.Count > 0 Then e.Row.Cells(5).Text = ObjCGame.DtResultados(0)("Primera").ToString().FormatoNumero() e.Row.Cells(6).Text = ObjCGame.DtResultados(0)("Segunda").ToString().FormatoNumero() e.Row.Cells(7).Text = ObjCGame.DtResultados(0)("Merma").ToString().FormatoNumero() End If End If ObjCGame.Dispose() End If End Sub Protected Sub GvFacturacion_RowDataBound(sender As Object, e As GridViewRowEventArgs) If (e.Row.RowType = DataControlRowType.DataRow) Then If e.Row.DataKey("CveTipoEtiqueta").ToEntero = 1 Then e.Row.FCLabel("LblTipoEtiqueta").Text = "Si" ElseIf e.Row.RowIndex > 0 Then e.Row.FCLabel("LblTipoEtiqueta").Text = "No" End If End If End Sub #End Region #Region "CREAR A PARTIR DE" Private Sub BtnCreaPartir_Click(sender As Object, e As EventArgs) Handles BtnCreaPartir.Click CargaFolio() lblNombreUsuario.Text = UsuarioActual.Nombre TxtFecha.Text = Now.AddDays(0).ToShortDateString TxtFechaEntrega.Text = Now.AddDays(0).ToShortDateString TrEstatus.Visible = False CveOrdenProduccion = -1 LnkEliminarOrdenProduccion.Visible = False LnkSinFletes.Visible = False LnkAbrirOrdenProduccion.Visible = False DivPorcentaje.Visible = False BtnCreaPartir.Visible = False TabEmpaqueUSA.Visible = False TabEmpaque.Visible = False TabAvance.Visible = False TabCortes.Visible = False TabFacturacion.Visible = False TabLiquidacion.Visible = False BtnClonar.Visible = False For Each dt As DataRow In DtDetalle.Rows dt("CveOrdenProduccionDetalle") = -1 Next UpEstatus.Update() UpTabs.Update() UPDatosOrden.Update() UpPorcentaje.Update() End Sub #End Region #Region "GENERAR ORDEN DE CORTE" 'Protected Sub LnkGenerarOrdenCorte_Click(sender As Object, e As EventArgs) ' Dim ObjCGame As New ClsCGame ' If ObjCGame.GetOrdenCorte(UsuarioActual.CveEmpresa) Then ' If Not ObjCGame.DtResultados.Rows.Count > 0 Then ' TabOrdenCorte.Visible = True ' Tab.ActiveTabIndex = 1 ' UpTabs.Update() ' Else ' Alert("Ya fue generada una orden de corte", TipoMensaje.MsgAdvertencia) ' End If ' End If ' ObjCGame.Dispose() 'End Sub 'Protected Sub Dividir(sender As Object, e As EventArgs) ' Dim Cont As Integer = 0 ' For Each Row As DataRow In DtDetalleCorte.Rows ' If GvOrdenCorte.Rows(Cont).FCTextBox("TxtFechaCorte").Text <> "" Then ' Row("FechaCorte") = GvOrdenCorte.Rows(Cont).FCTextBox("TxtFechaCorte").Text ' End If ' If GvOrdenCorte.Rows(Cont).FCDropDownList("DdlHuerta").SelectedValue <> "-1" Then ' Row("CveHuerta") = GvOrdenCorte.Rows(Cont).FCDropDownList("DdlHuerta").SelectedValue ' End If ' If GvOrdenCorte.Rows(Cont).FCTextBox("TxtPeso").Text <> "" Then ' Row("Peso") = GvOrdenCorte.Rows(Cont).FCTextBox("TxtPeso").Text ' End If ' If GvOrdenCorte.Rows(Cont).FCTextBox("TxtCuadro").Text <> "" Then ' Row("Cuadro") = GvOrdenCorte.Rows(Cont).FCTextBox("TxtCuadro").Text ' End If ' If GvOrdenCorte.Rows(Cont).FCTextBox("TxtObservacion").Text <> "" Then ' Row("Observacion") = GvOrdenCorte.Rows(Cont).FCTextBox("TxtObservacion").Text ' End If ' Cont += 1 ' Next ' Dim Index = CType(sender, LinkButton).CommandArgument.ToString().ToEntero() ' Dim Cantidad = HdnCantidad.Value.ToEntero() ' Dim Dr As DataRow = DtDetalleCorte.Rows(Index) ' Dim DrNew As DataRow = DtDetalleCorte.NewRow ' DrNew.ItemArray = Dr.ItemArray ' Dr("Cantidad") = (Dr("Cantidad").ToString.ToEntero - Cantidad) ' DrNew("Cantidad") = Cantidad ' DrNew("CveHuerta") = -1 ' DrNew("Peso") = 0.0 ' DrNew("Cuadro") = 0 ' DrNew("Observacion") = "" ' DrNew("FechaCorte") = Date.Now.ToShortDateString ' DtDetalleCorte.Rows.InsertAt(DrNew, Index) ' DtDetalleCorte.AcceptChanges() ' GvOrdenCorte.DataSource = DtDetalleCorte ' GvOrdenCorte.DataBind() ' Cont = 0 ' For Each Row As DataRow In DtDetalleCorte.Rows ' If Row("FechaCorte").ToString <> "" Then ' GvOrdenCorte.Rows(Cont).FCTextBox("TxtFechaCorte").Text = Row("FechaCorte").ToString ' End If ' If Row("Peso").ToString <> "" Then ' GvOrdenCorte.Rows(Cont).FCTextBox("TxtPeso").Text = Row("Peso").ToString ' End If ' If Row("CveHuerta").ToString <> "" Then ' GvOrdenCorte.Rows(Cont).FCDropDownList("DdlHuerta").SelectedValue = Row("CveHuerta").ToString ' End If ' If Row("Cuadro").ToString <> "" Then ' GvOrdenCorte.Rows(Cont).FCTextBox("TxtCuadro").Text = Row("Cuadro").ToString ' End If ' If Row("Observacion").ToString <> "" Then ' GvOrdenCorte.Rows(Cont).FCTextBox("TxtObservacion").Text = Row("Observacion").ToString ' End If ' Cont += 1 ' Next ' UpOrdenCorte.Update() 'End Sub 'Protected Sub BtnOrdenCorteAdd_Click(sender As Object, e As EventArgs) ' Dim ErrorGv = False ' For Each Row As GridViewRow In GvOrdenCorte.Rows ' If Row.FCDropDownList("DdlHuerta").SelectedValue = "-1" OrElse Row.FCTextBox("TxtFechaCorte").Text = "" OrElse Row.FCTextBox("TxtPeso").Text.ToEntero <= 0 OrElse Row.FCTextBox("TxtCuadro").Text = "" Then ' ErrorGv = True ' End If ' Next ' If Not ErrorGv Then ' Dim CveOrdenCorte As Integer = 0 ' Dim ErrorTrans = False ' Dim Dt As New DataTable ' Dt.Columns.Add("CveOrdenCorte", GetType(Integer)) ' Dt.Columns.Add("CveHuerta", GetType(Integer)) ' Dt.Columns.Add("FechaEntrega", GetType(String)) ' Dt.Columns.Add("Peso", GetType(Double)) ' Dt.Columns.Add("Cuadro", GetType(Integer)) ' Dt.Columns.Add("Observacion", GetType(String)) ' For Each Row As GridViewRow In GvOrdenCorte.Rows ' Dim x As Integer = 0 ' For Each Dr As DataRow In Dt.Rows ' If Row.FCDropDownList("DdlHuerta").SelectedValue.ToEntero = Dr("CveHuerta").ToString.ToEntero Then ' x = 1 ' End If ' Next ' If x = 0 Then ' Dim Dr As DataRow = Nothing ' Dr = Dt.NewRow ' Dr("CveHuerta") = Row.FCDropDownList("DdlHuerta").SelectedValue.ToEntero ' Dr("FechaEntrega") = Row.FCTextBox("TxtFechaCorte").Text ' Dr("Peso") = Row.FCTextBox("TxtPeso").Text.ToDouble ' Dr("Cuadro") = Row.FCTextBox("TxtCuadro").Text.ToDouble ' Dr("Observacion") = Row.FCTextBox("TxtObservacion").Text ' Dt.Rows.Add(Dr) ' Dt.AcceptChanges() ' End If ' Next ' Dim ObjCGame As New ClsCGame ' ObjCGame.IniciaTransacSQL() ' For Each Dr As DataRow In Dt.Rows ' If ObjCGame.AddOrdenCorte(CveOrdenProduccion, Dr("CveHuerta").ToString.ToEntero, "", Dr("FechaEntrega").ToString.ToDate, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Dr("Peso").ToString().ToDouble(), Dr("Cuadro").ToString.ToEntero, Dr("Observacion").ToString()) Then ' CveOrdenCorte = ObjCGame.CveOrdenCorte ' Dr("CveOrdenCorte") = CveOrdenCorte ' Dt.AcceptChanges() ' For Each Row As GridViewRow In GvOrdenCorte.Rows ' If Row.FCDropDownList("DdlHuerta").SelectedValue.ToEntero = Dr("CveHuerta").ToString.ToEntero Then ' If ObjCGame.AddOrdenCorteDetalle(Row.FCLabel("LblCantidad").Text.ToEntero, CveOrdenCorte, Row.DataKey("CveOrdenProduccionDetalle").ToEntero) = False Then ' ErrorTrans = True ' End If ' End If ' Next ' Else ' ErrorTrans = True ' End If ' Next ' If Not ObjCGame.UpdateOrdenProduccionEstatus(CveOrdenProduccion, 2) Then ' ErrorTrans = True ' Else ' LblEstatus.Text = "En proceso de corte" ' End If ' If Not ErrorTrans Then ' ObjCGame.Commit() ' If ObjCGame.GetOrdenCorte(UsuarioActual.CveEmpresa, CveOrdenProduccion:=CveOrdenProduccion) Then ' If ObjCGame.DtResultados.Rows.Count > 0 Then ' TabCortes.Visible = True ' GvCortes.DataSource = ObjCGame.DtResultados ' GvCortes.DataBind() ' End If ' End If ' Envio(Dt, -1, "OC") ' Else ' ObjCGame.RollBack() ' End If ' ObjCGame.Dispose() ' UpEstatus.Update() ' Else ' Alert("Todos los productos deben tener fecha, huerta, peso, cuadro y observación", TipoMensaje.MsgAdvertencia) ' End If 'End Sub #End Region #Region "CORREO" Private Function GeneraCorreoOP(_CveOrdenProduccion As Integer, Optional Dt As DataTable = Nothing) As String Dim ObjCGame As New ClsCGame ObjCGame.GetOrdenProduccion(_CveOrdenProduccion, UsuarioActual.CveEmpresa, -1, "-1", MinFecha, MaxFecha, -1) Dim strBody As New StringBuilder strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") strBody.Append(" ") If TxtNumClonar.Text <> "" Then Dim FEntrega = ObjCGame.DtResultados(0)("FEntrega").ToString().ToDate().ToShortDateString() Dim Cliente = ObjCGame.DtResultados(0)("Cliente").ToString() Dim NombreUsuario = ObjCGame.DtResultados(0)("NombreUsuario").ToString() Dim Observaciones = ObjCGame.DtResultados(0)("Observaciones").ToString() Dim DtOrdenProduccionDetalleResumen As DataTable = Nothing Dim Crea = 0 strBody.Append("
") strBody.Append("
") strBody.Append(" Resumen de las Ordenes de Producción Clonadas ") strBody.Append(" ") strBody.Append(" ") For Each drr As DataRow In Dt.Rows If ObjCGame.GetOrdenProduccionDetalle(drr("CveOrdenProduccion").ToString.ToEntero(), UsuarioActual.CveEmpresa) Then If Crea = 0 Then DtOrdenProduccionDetalleResumen = ObjCGame.DtResultados.Copy For Each dr As DataRow In DtOrdenProduccionDetalleResumen.Rows dr("Cantidad") = 0 Next Crea = 1 End If Dim Cont = 0 For Each dr As DataRow In ObjCGame.DtResultados.Rows DtOrdenProduccionDetalleResumen.Rows(Cont)("Cantidad") = DtOrdenProduccionDetalleResumen.Rows(Cont)("Cantidad").ToString.ToEntero + dr("Cantidad").ToString.ToEntero Cont += 1 Next End If Next For Each dr As DataRow In DtOrdenProduccionDetalleResumen.Rows Dim TipoEtiqueta As String If Convert.ToBoolean(dr("CveTipoEtiqueta")) Then TipoEtiqueta = "Si" Else TipoEtiqueta = "No" End If strBody.AppendFormat("", dr("Cantidad").ToString.FormatoNumero(0), dr("PS"), dr("TipoProducto"), dr("TipoMaduracion"), dr("TipoEmpaque"), dr("Tamaño"), TipoEtiqueta, dr("Calidad"), dr("TipoCaja"), dr("Instrucciones"), dr("Observaciones")) Next strBody.Append("
CantidadFrutoTipo ProducciónVariedadTipo EmpaqueTamañoPLUCalidadEtiquetaInstruccionesObservaciones
{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}
") strBody.Append("
") strBody.Append("
") strBody.Append("
") strBody.Append("
") strBody.Append("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------") For Each drr As DataRow In Dt.Rows strBody.Append("
") strBody.AppendFormat("
Datos {0} ", "de la orden de producción") strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", FEntrega) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", Cliente) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", NombreUsuario) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", Observaciones) strBody.Append(" ") strBody.Append("
Folio OP: " + drr("Folio").ToString() + " F. Entrega:{0}
Cliente:{0}  
Solicita:{0}  
Observacion General:{0}  
") strBody.Append("
") strBody.Append("
") strBody.Append("
") strBody.Append("
") strBody.Append(" Instrucciones de la Producción ") strBody.Append(" ") strBody.Append(" ") Dim DtOrdenProduccionDetalle As DataTable = Nothing If ObjCGame.GetOrdenProduccionDetalle(drr("CveOrdenProduccion").ToString.ToEntero(), UsuarioActual.CveEmpresa) Then DtOrdenProduccionDetalle = ObjCGame.DtResultados End If For Each dr As DataRow In DtOrdenProduccionDetalle.Rows Dim TipoEtiqueta As String If Convert.ToBoolean(dr("CveTipoEtiqueta")) Then TipoEtiqueta = "Si" Else TipoEtiqueta = "No" End If strBody.AppendFormat("", dr("Cantidad").ToString.FormatoNumero(0), dr("PS"), dr("TipoProducto"), dr("TipoMaduracion"), dr("TipoEmpaque"), dr("Tamaño"), TipoEtiqueta, dr("Calidad"), dr("TipoCaja"), dr("Instrucciones"), dr("Observaciones")) Next strBody.Append("
CantidadFrutoTipo ProducciónVariedadTipo EmpaqueTamañoPLUCalidadEtiquetaInstruccionesObservaciones
{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}
") strBody.Append("
") strBody.Append("
") strBody.Append("
") strBody.AppendFormat("" + "Ir a la Orden de Producción" + "") strBody.Append("
") strBody.Append("
") strBody.Append("
") strBody.Append("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------") Next Else strBody.Append("
") strBody.AppendFormat("
Datos {0} ", "de la orden de producción") strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ") strBody.AppendFormat(" ", ObjCGame.DtResultados(0)("FEntrega").ToString().ToDate().ToShortDateString()) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", ObjCGame.DtResultados(0)("Cliente").ToString()) strBody.Append(" ") If ObjCGame.DtResultados(0)("FechaEmpaqueUSA").ToString.ToDate > MinFecha Then strBody.Append(" ") strBody.AppendFormat(" ", ObjCGame.DtResultados(0)("FechaEmpaqueUSA").ToString().ToDate().ToShortDateString()) strBody.Append(" ") End If strBody.Append(" ") strBody.AppendFormat(" ", ObjCGame.DtResultados(0)("NombreUsuario").ToString()) strBody.Append(" ") strBody.Append(" ") strBody.AppendFormat(" ", ObjCGame.DtResultados(0)("Observaciones").ToString()) strBody.Append(" ") strBody.Append("
Folio OP: " + ObjCGame.DtResultados(0)("Folio").ToString() + " F. Entrega:{0}
Cliente:{0}  
F. Flete:{0}  
Solicita:{0}  
Observacion General:{0}  
") strBody.Append("
") strBody.Append("
") If Not CveOrdenProduccion > 0 Or LtlPorcentajeTotal.Text.ToDouble() = 100 Then strBody.Append("
") strBody.Append("
") strBody.Append(" Instrucciones de la Producción ") strBody.Append(" ") strBody.Append(" ") Dim DtOrdenProduccionDetalle As DataTable = Nothing If ObjCGame.GetOrdenProduccionDetalle(_CveOrdenProduccion, UsuarioActual.CveEmpresa) Then DtOrdenProduccionDetalle = ObjCGame.DtResultados End If For Each dr As DataRow In DtOrdenProduccionDetalle.Rows Dim TipoEtiqueta As String If Convert.ToBoolean(dr("CveTipoEtiqueta")) Then TipoEtiqueta = "Si" Else TipoEtiqueta = "No" End If strBody.AppendFormat("", dr("Cantidad").ToString.FormatoNumero(0), dr("PS"), dr("TipoProducto"), dr("TipoMaduracion"), dr("TipoEmpaque"), dr("Tamaño"), TipoEtiqueta, dr("Calidad"), dr("TipoCaja"), dr("Instrucciones"), dr("Observaciones")) Next strBody.Append("
CantidadFrutoTipo ProducciónVariedadTipo EmpaqueTamañoPLUCalidadEtiquetaInstruccionesObservaciones
{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}
") strBody.Append("
") strBody.Append("
") End If strBody.Append("
") strBody.AppendFormat("
" + "Ir a la Orden de Producción" + "") strBody.Append("
") End If strBody.Append("") ObjCGame.Dispose() Return strBody.ToString End Function Private Sub MandaCorreo(Para As String, Asunto As String, Body As String) Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) Dim Mail As New ClsSisMail() Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body) End Sub Protected Sub EnvioCorreo(Dt As DataTable, CveOrdenProduccion As Integer, Opcion As String) Dim Body As String = "" Dim Asunto As String = "" Dim Correo As String = "" 'Correo = "julian@adsistemas.mx" 'Correo = "dany_pimi@hotmail.com" If Opcion = "OP" Then If TxtNumClonar.Text <> "" Then Dim Folio As String = "" For Each dr As DataRow In Dt.Rows If Folio = "" Then Folio = dr("Folio").ToString() Else Folio = Folio + " - " + dr("Folio").ToString() End If Next Asunto = "SIG - Se Genero una Orden de Producción con el folio: " + Folio Body = GeneraCorreoOP(CveOrdenProduccion, Dt) Else Asunto = "SIG - Se Genero una Orden de Producción con el folio: " + Folio Body = GeneraCorreoOP(CveOrdenProduccion) End If Correo = "enrique@flavorkingfarms.com;monica@citrusgame.com.mx;enrique@citrusgame.com.mx;fernanda@citrusgame.com.mx;julio@citrusgame.com.mx;norberto@citrusgame.com.mx;rene@citrusgame.com.mx;sergio@citrusgame.com.mx;eduardo@citrusgame.com.mx;" ElseIf Opcion = "UpFlete" Then Body = GeneraCorreoOP(CveOrdenProduccion) Asunto = "SIG - Solicitud de Flete Empaque USA para la orden de produccion con el folio: " + Folio + " y con la fecha: " + TxtFechaFlete.Text Correo = "cesar@citrusgame.com.mx" 'Correo = "eduardo@citrusgame.com.mx;monica@citrusgame.com.mx;rene@citrusgame.com.mx;sergio@citrusgame.com.mx" ElseIf Opcion = "SUR" Then Body = GeneraCorreoOP(CveOrdenProduccion) Asunto = "SIG - La Orden de Producción con el folio: " + Folio + " ha sido surtida " Correo = "enrique@flavorkingfarms.com;sergio@citrusgame.com.mx;monica@citrusgame.com.mx;rene@citrusgame.com.mx;sergio@citrusgame.com.mx;" End If Try Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Correo, Asunto, Body)) Hilo.Start() If Opcion = "SUR" Then Dim ObjCGame As New ClsCGame ObjCGame.UpdateOrdenProduccionEnvioCorreo(CveOrdenProduccion) ObjCGame.Dispose() End If Tab.ActiveTabIndex = 0 UpTabs.Update() Catch ex As Exception OnError("Ocurrió error al mandar MAIL", ex) End Try End Sub #End Region #Region "AGREGAR FLETES" Protected Sub LnkFletes_Click(sender As Object, e As EventArgs) Response.Redirect(String.Format("{0}{1}", "/CGame/Fletes.aspx?CveOrdenProduccion=", CveOrdenProduccion), True) UpAcciones.Update() End Sub #End Region #Region "MANIFIESTO" Protected Sub BtnManifiesto_Click(sender As Object, e As EventArgs) RegistraScript("$('#DivManifiesto').modal()") TxtNombreManifiesto.Text = "" TxtDireccionManifiesto.Text = "" TxtCiudadManifiesto.Text = "" TxtFechaManifiesto.Text = Now.ToShortDateString() UpManifiesto.Update() End Sub Protected Sub BtnModalManifiesto_Click(sender As Object, e As EventArgs) Dim ObjCGame As New ClsCGame If ObjCGame.UpdateOrdenProduccionManifiesto(CveOrdenProduccion, TxtNombreManifiesto.Text, TxtDireccionManifiesto.Text, TxtCiudadManifiesto.Text, TxtFechaManifiesto.Text.ToDate) Then PDF(ObjCGame) End If ObjCGame.Dispose() RegistraScript("$('#DivManifiesto').modal('hide')") End Sub Private Sub PDF(ObjCGame As ClsCGame) If ObjCGame.GetOrdenProduccion(CveOrdenProduccion, UsuarioActual.CveEmpresa, -1, "-1", MinFecha, MaxFecha, -1) Then If ObjCGame.DtResultados.Rows.Count > 0 Then Dim Dt As New DataTable Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png") Dim params As New List(Of ReportParameter) params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) params.Add(New ReportParameter("Folio", ObjCGame.DtResultados.Rows(0)("Folio").ToString)) params.Add(New ReportParameter("Nombre", ObjCGame.DtResultados.Rows(0)("Nombre").ToString)) params.Add(New ReportParameter("Direccion", ObjCGame.DtResultados.Rows(0)("Direccion").ToString)) params.Add(New ReportParameter("Ciudad", ObjCGame.DtResultados.Rows(0)("Ciudad").ToString)) params.Add(New ReportParameter("Fecha", ObjCGame.DtResultados.Rows(0)("Fecha").ToString.ToDate.ToShortDateString)) params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))) If ObjCGame.GetAvance(CveOrdenProduccion, UsuarioActual.CveEmpresa) Then Dt = ObjCGame.DtResultados If Dt.Rows.Count > 0 Then params.Add(New ReportParameter("Manifiesto", Dt.Rows(0)("Manifiesto").ToString)) params.Add(New ReportParameter("SubTotal", Dt.SUM("Importe").ToString.FormatoNumero())) params.Add(New ReportParameter("CantidadConLetra", Texto2Letras(Dt.SUM("Importe").ToString.ToDouble, 2))) End If End If ImprimirPDF("Empresas/Grales/Formatos/Manifiesto.rdlc", Dt, params, String.Format("Manifiesto -{0}", Now.ToDateTime.ToShortDateString)) Else Alert("No se encontraron resultados", TipoMensaje.MsgAdvertencia) End If End If End Sub #End Region #Region "LIQUIDACION" Private Sub CargaGvLiquidacion() Dim ObjCGame As New ClsCGame If ObjCGame.GetOrdenProduccionDetalleLiquidacion(UsuarioActual.CveEmpresa, CveOrdenProduccion) Then GvLiquidacion.DataSource = ObjCGame.DtResultados End If GvLiquidacion.DataBind() UpLiquidacion.Update() End Sub Private Sub CargaGvLiquidacionModal(CvePS As Integer, CveTipoProducto As Integer, CveTipoMaduracion As Integer, CveTamaño As Integer, CveTipoCaja As Integer) Dim ObjCGame As New ClsCGame If ObjCGame.GetLiquidacion(CveOrdenProduccion, CvePS, CveTipoProducto, CveTipoMaduracion, CveTamaño, CveTipoCaja) Then GvLiquidacionModal.DataSource = ObjCGame.DtResultados DtLiquidacion = ObjCGame.DtResultados End If GvLiquidacionModal.DataBind() End Sub Private Sub LimpiaModalLiquidacion() TxtCantidadLiquidacion.Text = "" TxtPU.Text = "" TxtPesoPagado.Text = "" End Sub Protected Sub BtnAddLiquidacion_Click(sender As Object, e As EventArgs) Dim ObjCGame As New ClsCGame ObjCGame.IniciaTransacSQL() Dim ErrorTrans As Boolean = False If Not ObjCGame.RemoveLiquidacion(CveOrdenProduccion, CvePS, CveTipoProducto, CveTipoMaduracion, CveTamaño, CveTipoCaja) Then ErrorTrans = True End If For Each Dr As DataRow In DtLiquidacion.Rows If Not ObjCGame.AddLiquidacion(CveOrdenProduccion, CvePS, CveTipoProducto, CveTipoMaduracion, CveTamaño, CveTipoCaja, Dr("Cantidad").ToString.ToEntero, Dr("PU").ToString.ToDouble, Dr("PesoPagado").ToString.ToDouble) Then ErrorTrans = True End If Next If Not ErrorTrans Then ObjCGame.Commit() Alert("Liquidacion actualizada correctamente") CargaGvLiquidacion() RegistraScript("$('#DivLiquidacion').modal('hide')") Else ObjCGame.RollBack() End If ObjCGame.Dispose() End Sub Protected Sub LnkAddLiquidacion_Click(sender As Object, e As EventArgs) Dim Dr As DataRow = Nothing Dr = DtLiquidacion.NewRow Dr("Cantidad") = TxtCantidadLiquidacion.Text.ToEntero Dr("PU") = TxtPU.Text.ToDouble Dr("PesoPagado") = TxtPesoPagado.Text.ToDouble DtLiquidacion.Rows.InsertAt(Dr, DtLiquidacion.Rows.Count) DtLiquidacion.AcceptChanges() CargaGvLModal() XLiquidar = Liquidado - DtLiquidacion.SUM("Cantidad").ToEntero RVCant.MaximumValue = If(XLiquidar < 1, 1, XLiquidar).ToString RVCant.ErrorMessage = $"La cantidad debe de estar entre 1 y {XLiquidar.ToString.FormatoNumero(0)} " If Not XLiquidar > 0 Then LnkAddLiquidacion.Enabled = False : TxtCantidadLiquidacion.Enabled = False : TxtPU.Enabled = False : TxtPesoPagado.Enabled = False Else LnkAddLiquidacion.Enabled = True : TxtCantidadLiquidacion.Enabled = True : TxtPU.Enabled = True : TxtPesoPagado.Enabled = True : BtnAddLiquidacion.Enabled = True LimpiaModalLiquidacion() UpModalLiquidacion.Update() End Sub Protected Sub LnkEliminarLiquidacion_Click(sender As Object, e As EventArgs) Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) DtLiquidacion.Rows.RemoveAt(gvRow.RowIndex) DtLiquidacion.AcceptChanges() CargaGvLModal() XLiquidar = Liquidado - DtLiquidacion.SUM("Cantidad").ToEntero RVCant.MaximumValue = If(XLiquidar < 1, 1, XLiquidar).ToString RVCant.ErrorMessage = $"La cantidad debe de estar entre 1 y {XLiquidar.ToString.FormatoNumero(0)} " If Not XLiquidar > 0 Then LnkAddLiquidacion.Enabled = False : TxtCantidadLiquidacion.Enabled = False : TxtPU.Enabled = False : TxtPesoPagado.Enabled = True : Else LnkAddLiquidacion.Enabled = True : TxtCantidadLiquidacion.Enabled = True : TxtPU.Enabled = True : TxtPesoPagado.Enabled = True : BtnAddLiquidacion.Enabled = True UpModalLiquidacion.Update() End Sub Private Sub CargaGvLModal() GvLiquidacionModal.DataSource = DtLiquidacion GvLiquidacionModal.DataBind() End Sub Protected Sub LnkEditarLiquidacion_Click(sender As Object, e As EventArgs) Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) LimpiaModalLiquidacion() LblFruto.Text = gvRow.DataKey("PS").ToString LblTipoProduccion.Text = gvRow.DataKey("TipoProducto").ToString LblVariedad.Text = gvRow.DataKey("TipoMaduracion").ToString LblTipoCaja.Text = gvRow.DataKey("TipoCaja").ToString LblTamaño.Text = gvRow.DataKey("Tamaño").ToString CvePS = gvRow.DataKey("CvePS").ToEntero CveTipoProducto = gvRow.DataKey("CveTipoProducto").ToEntero CveTipoMaduracion = gvRow.DataKey("CveTipoMaduracion").ToEntero CveTamaño = gvRow.DataKey("CveTamaño").ToEntero CveTipoCaja = gvRow.DataKey("CveTipoCaja").ToEntero XLiquidar = gvRow.DataKey("XLiquidar").ToEntero Liquidado = gvRow.DataKey("Liquidado").ToEntero RVCant.MaximumValue = If(XLiquidar < 1, 1, XLiquidar).ToString RVCant.ErrorMessage = $"La cantidad debe de estar entre 1 y {XLiquidar.ToString.FormatoNumero(0)} " If Not XLiquidar > 0 Then LnkAddLiquidacion.Enabled = False : TxtCantidadLiquidacion.Enabled = False : TxtPU.Enabled = False : TxtPesoPagado.Enabled = False : BtnAddLiquidacion.Enabled = False Else LnkAddLiquidacion.Enabled = True : TxtCantidadLiquidacion.Enabled = True : TxtPU.Enabled = True : TxtPesoPagado.Enabled = True : BtnAddLiquidacion.Enabled = True CargaGvLiquidacionModal(CvePS, CveTipoProducto, CveTipoMaduracion, CveTamaño, CveTipoCaja) UpModalLiquidacion.Update() RegistraScript("$('#DivLiquidacion').modal()") CargaGvLiquidacion() End Sub Protected Sub GvLiquidacion_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowIndex = 0 Then e.Row.CssClass = "Totales" e.Row.Cells(0).Text = "Total" End If End If End Sub #End Region #Region "GASTOS" Private Sub CargaGastos() Dim ObjCGame As New ClsCGame If ObjCGame.GetOrdenProduccionGasto(CveOrdenProduccion) Then If ObjCGame.DtResultados.Rows.Count > 0 Then Dim DtOPGastos As DataTable = ObjCGame.DtResultados.Copy Dim DtOPGastosCalculados As DataTable = Nothing If ObjCGame.GetOrdenProduccionGastosCalculados(CveOrdenProduccion) Then DtOPGastosCalculados = ObjCGame.DtResultados End If ModalidadLiquidacion = "U" BtnLiquidarGasto.Text = "Actualizar Liquidación Gasto" For Each Gvr As GridViewRow In GvGastos.Rows For Each Dr As DataRow In DtOPGastosCalculados.Rows If Gvr.DataKey("Tipo").ToEntero = 1 Then If Gvr.DataKey("TipoCalculado").ToString = "COR" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Corte").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "FHE" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("FleteHuertaEmpaque").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "MAQ" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Maquila").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "PEF" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("ImportePreEnfriado").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "FHN" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("FleteHermosilloNogales").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "BT" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("BinsTapas").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "CJ" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Cajas").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "CJM" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("CajasMaster").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "TMR" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Tarimas").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "MLL" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Mallas").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "ESQ" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Esquineros").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "GFFC" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Gastos").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "PRSV" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("ProgramaSanidad").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "TARB" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("TarimasBins").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "CER" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Certificado").ToString.FormatoNumero End If Else If Gvr.DataKey("TipoCalculado").ToString = "CMC" Then Gvr.Visible = False End If Next Dim Entro As Boolean = False For Each Dr As DataRow In DtOPGastos.Rows If Gvr.DataKey("CveCargoFijo").ToEntero = Dr("CveCargoFijo").ToString.ToEntero Then Gvr.FCTextBox("TxtImporte").Text = Dr("Importe").ToString.FormatoNumero Entro = True End If Next If Not Entro Then Gvr.FCCheckBox("ChkGasto").Checked = False End If Next Else If ObjCGame.GetOrdenProduccionGastosCalculados(CveOrdenProduccion) Then If ObjCGame.DtResultados.Rows.Count > 0 Then For Each Gvr As GridViewRow In GvGastos.Rows Gvr.FCCheckBox("ChkGasto").Checked = True If Gvr.DataKey("Tipo").ToEntero = 1 Then If Gvr.DataKey("TipoCalculado").ToString = "COR" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Corte").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "FHE" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("FleteHuertaEmpaque").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "MAQ" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Maquila").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "PEF" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("ImportePreEnfriado").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 2 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "FHN" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("FleteHermosilloNogales").ToString.FormatoNumero ElseIf Gvr.DataKey("TipoCalculado").ToString = "BT" Then Gvr.FCTextBox("TxtImporte").Enabled = False Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("BinsTapas").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 1 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "CJ" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Cajas").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 2 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "CJM" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("CajasMaster").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 2 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "TMR" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Tarimas").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 2 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "MLL" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Mallas").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 2 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "ESQ" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Esquineros").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 2 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "GFFC" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Gastos").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 2 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "PRSV" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("ProgramaSanidad").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 2 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "TARB" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("TarimasBins").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 1 Then Gvr.FCCheckBox("ChkGasto").Checked = False ElseIf Gvr.DataKey("TipoCalculado").ToString = "CER" Then Gvr.FCTextBox("TxtImporte").Text = ObjCGame.DtResultados(0)("Certificado").ToString.FormatoNumero If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 1 Then Gvr.FCCheckBox("ChkGasto").Checked = False End If Else If Gvr.DataKey("TipoCalculado").ToString = "FO5" Then If ObjCGame.DtResultados(0)("TipoEmpaque").ToString.ToEntero = 1 Then Gvr.FCCheckBox("ChkGasto").Checked = False End If If Gvr.DataKey("TipoCalculado").ToString = "CMC" Then Gvr.Visible = False End If Next End If ModalidadLiquidacion = "A" BtnLiquidarGasto.Text = "Liquidar Gasto" End If End If End If ObjCGame.Dispose() UpGastos.Update() End Sub Protected Sub BtnLiquidarGasto_Click(sender As Object, e As EventArgs) Dim ObjCGame As New ClsCGame ObjCGame.IniciaTransacSQL() Dim ErrorTrans As Boolean = False If ModalidadLiquidacion = "U" Then If Not ObjCGame.RemoveOrdenProduccionGasto(CveOrdenProduccion) Then ErrorTrans = True End If End If For Each Gvr As GridViewRow In GvGastos.Rows If Gvr.FCCheckBox("ChkGasto").Checked Then If Not ObjCGame.AddOrdenProduccionGasto(CveOrdenProduccion, Gvr.DataKey("CveCargoFijo").ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDouble) Then ErrorTrans = True End If End If Next If Not ErrorTrans Then ObjCGame.Commit() Alert("Liquidada correctamente", TipoMensaje.MsgInformacion, $"document.location.href=""/CGame/OrdenProduccion.aspx?CveOrdenProduccion={CveOrdenProduccion}""") Else ObjCGame.RollBack() End If ObjCGame.Dispose() End Sub #End Region End Class