Пример #1
0
        public static Orden_trabajo OrdenTrabajoAdd(Orden_trabajo o)
        {
            IDbTransaction trans = null;

            try
            {
                trans   = GenericDataAccess.BeginTransaction();
                o.Folio = FolioCtrl.getFolio(enumTipo.OT, trans);
                Orden_trabajoMng oMng = new Orden_trabajoMng()
                {
                    O_Orden_trabajo = o
                };
                oMng.add(trans);
                Orden_trabajo_servicioMng oOTSMng = new Orden_trabajo_servicioMng();
                foreach (Orden_trabajo_servicio itemOTS in o.PLstOTSer)
                {
                    itemOTS.Id_orden_trabajo         = o.Id;
                    oOTSMng.O_Orden_trabajo_servicio = itemOTS;
                    oOTSMng.add(trans);
                }
                GenericDataAccess.CommitTransaction(trans);
            }
            catch
            {
                if (trans != null)
                {
                    GenericDataAccess.RollbackTransaction(trans);
                }
                throw;
            }
            return(o);
        }
Пример #2
0
 protected void BindByDataRow(DataRow dr, Orden_trabajo o)
 {
     try
     {
         int.TryParse(dr["id"].ToString(), out entero);
         o.Id                 = entero;
         entero               = 0;
         o.Folio              = dr["folio"].ToString();
         o.Referencia         = dr["referencia"].ToString();
         o.Referencia_entrada = dr["referencia_entrada"].ToString();
         if (dr["fecha"] != DBNull.Value)
         {
             DateTime.TryParse(dr["fecha"].ToString(), out fecha);
             o.Fecha = fecha;
             fecha   = default(DateTime);
         }
         if (dr["cerrada"] != DBNull.Value)
         {
             bool.TryParse(dr["cerrada"].ToString(), out logica);
             o.Cerrada = logica;
             logica    = false;
         }
         o.Supervisor = dr["supervisor"].ToString();
     }
     catch
     {
         throw;
     }
 }
Пример #3
0
 public override void fillLst()
 {
     try
     {
         this.comm = GenericDataAccess.CreateCommandSP("sp_Orden_trabajo");
         addParameters(0);
         this.dt   = GenericDataAccess.ExecuteSelectCommand(comm);
         this._lst = new List <Orden_trabajo>();
         foreach (DataRow dr in dt.Rows)
         {
             Orden_trabajo o = new Orden_trabajo();
             BindByDataRow(dr, o);
             this._lst.Add(o);
         }
     }
     catch
     {
         throw;
     }
 }
Пример #4
0
 internal void fillLstCloseOrOpen()
 {
     try
     {
         this.comm = GenericDataAccess.CreateCommandSP("sp_Orden_trabajo");
         addParameters(8);
         this.dt   = GenericDataAccess.ExecuteSelectCommand(comm);
         this._lst = new List <Orden_trabajo>();
         foreach (DataRow dr in dt.Rows)
         {
             Orden_trabajo o = new Orden_trabajo();
             BindByDataRow(dr, o);
             this._lst.Add(o);
             o.PEnt = new Entrada()
             {
                 Referencia = dr["refEnt"].ToString()
             };
         }
     }
     catch
     {
         throw;
     }
 }
Пример #5
0
        public static Orden_trabajo OrdenTrabajoGet(string folio)
        {
            Orden_trabajo o = new Orden_trabajo()
            {
                Folio = folio
            };

            try
            {
                Orden_trabajoMng oMng = new Orden_trabajoMng()
                {
                    O_Orden_trabajo = o
                };
                oMng.selByFolio();

                Orden_trabajo_servicioMng oOTSMng = new Orden_trabajo_servicioMng()
                {
                    O_Orden_trabajo_servicio = new Orden_trabajo_servicio()
                    {
                        Id_orden_trabajo = o.Id
                    }
                };
                oOTSMng.fillLstByIdOT();

                o.PLstOTSer = oOTSMng.Lst;

                Entrada_liverpoolMng oELMng = new Entrada_liverpoolMng();
                MaquilaMng           oMMng  = new MaquilaMng();
                Maquila_pasoMng      oMPMng = new Maquila_pasoMng();
                ServicioMng          oSMng  = new ServicioMng();
                foreach (Orden_trabajo_servicio itemOTS in o.PLstOTSer)
                {
                    int ref2 = 0;
                    int.TryParse(itemOTS.Ref2, out ref2);

                    Entrada_liverpool oEL = new Entrada_liverpool()
                    {
                        Trafico = itemOTS.Ref1, Pedido = ref2
                    };
                    oELMng.O_Entrada_liverpool = oEL;
                    oELMng.selByUniqueKey();
                    itemOTS.PEntLiv = oEL;

                    Servicio oS = new Servicio()
                    {
                        Id = itemOTS.Id_servicio
                    };
                    oSMng.O_Servicio = oS;
                    oSMng.selById();
                    itemOTS.PServ = oS;

                    Maquila oM = new Maquila()
                    {
                        Id_ord_tbj_srv = itemOTS.Id
                    };
                    oMMng.O_Maquila = oM;
                    oMMng.fillLstByOTS();
                    itemOTS.PLstMaq = oMMng.Lst;

                    itemOTS.PalletMaq = itemOTS.PLstMaq.Sum(p => p.Pallets);
                    itemOTS.BultosMaq = itemOTS.PLstMaq.Sum(p => p.Bultos);
                    itemOTS.PiezasMaq = itemOTS.PLstMaq.Sum(p => p.Piezas);
                    int dif = itemOTS.Piezas - itemOTS.PiezasMaq;
                    itemOTS.Faltantes = 0;
                    itemOTS.Sobrantes = 0;
                    if (itemOTS.PiezasMaq > 0)
                    {
                        if (dif > 0)
                        {
                            itemOTS.Faltantes = dif;
                        }
                        else
                        {
                            itemOTS.Sobrantes = Math.Abs(dif);
                        }
                    }

                    Maquila_paso oMP = new Maquila_paso()
                    {
                        Id_ord_tbj_srv = itemOTS.Id
                    };
                    oMPMng.O_Maquila_paso = oMP;
                    oMPMng.fillByIdOTS();
                    itemOTS.PLstPasos = oMPMng.Lst;

                    int numPaso = 1;
                    foreach (Maquila_paso itemMP in oMPMng.Lst)
                    {
                        itemMP.NumPaso = numPaso;
                        numPaso++;
                    }

                    itemOTS.PasosMaq = itemOTS.PLstPasos.Count();
                }
            }
            catch
            {
                throw;
            }
            return(o);
        }
Пример #6
0
 public Orden_trabajoMng()
 {
     this._oOrden_trabajo = new Orden_trabajo();
     this._lst            = new List <Orden_trabajo>();
 }