Beispiel #1
0
        public IList<KitAssembly> Select(KitAssembly data, int showRegs)
        {
            IList<KitAssembly> datos = new List<KitAssembly>();

            /*
                datos = GetHsql(data).List<KitAssembly>();
                if (!Factory.IsTransactional)
                    Factory.Commit();
                return datos;
            */
                try
                {
                    if (showRegs > 0)
                        datos = GetHsql(data).SetMaxResults(showRegs).List<KitAssembly>();
                    else
                        datos = GetHsql(data).List<KitAssembly>();

                    if (!Factory.IsTransactional)
                        Factory.Commit();
                }

                catch (Exception e)
                {
                    NHibernateHelper.WriteEventLog(WriteLog.GetTechMessage(e));
                }


                return datos;
        }
Beispiel #2
0
 public void UpdateKitAssembly(KitAssembly data) { Factory.DaoKitAssembly().Update(data); }
Beispiel #3
0
 public void DeleteKitAssembly(KitAssembly data) { Factory.DaoKitAssembly().Delete(data); }
Beispiel #4
0
 public KitAssembly SaveKitAssembly(KitAssembly data) { return Factory.DaoKitAssembly().Save(data); }
Beispiel #5
0
 public IList<KitAssembly> GetKitAssembly(KitAssembly data, int showRegs) { return Factory.DaoKitAssembly().Select(data, showRegs); }
Beispiel #6
0
        private IList<KitAssembly> GetKitAssembly(string sWhere)
        {
            //retorna la lista de Kits Headers

            try
            {

                Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString);

                Query = " select DISTINCT KIT_CODE from X_KIT WHERE DESC_TYPE=1 ";
                DataSet ds = ReturnDataSet(Query, sWhere, "X_KIT", Command.Connection);


                if (ds == null || ds.Tables.Count == 0)
                    return null;

                List<KitAssembly> list = new List<KitAssembly>();
                Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active });


                KitAssembly tmpData = null;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    try
                    {
                        //Map Properties
                        tmpData = new KitAssembly();

                        tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = dr["KIT_CODE"].ToString() }); ;
                        tmpData.Unit = tmpData.Product.BaseUnit;
                        tmpData.AsmType = 2;
                        tmpData.Status = status;
                        tmpData.EfectiveDate = DateTime.Now;
                        tmpData.ObsoleteDate = DateTime.Now;
                        tmpData.IsFromErp = true;

                        list.Add(tmpData);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            ExceptionMngr.WriteEvent("GetKitAssembly:" + tmpData.Product.ProductCode, ListValues.EventType.Error, ex, null,
                                ListValues.ErrorCategory.ErpConnection);
                        }
                        catch { }

                        //return null;
                    }

                }

                return list;


            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetKitAssembly Connection", ListValues.EventType.Error, ex, null,
                    ListValues.ErrorCategory.ErpConnection);

                return null;
            }
        }
Beispiel #7
0
 public Boolean Delete(KitAssembly data)
 {
     return base.Delete(data);
 }
Beispiel #8
0
 public KitAssembly SelectById(KitAssembly data)
 {
     return (KitAssembly)base.SelectById(data);
 }
Beispiel #9
0
 public Boolean Update(KitAssembly data)
 {
     return base.Update(data);
 }
Beispiel #10
0
 public KitAssembly Save(KitAssembly data)
 {
     return (KitAssembly)base.Save(data);
 }
        private IList<KitAssembly> GetKitAssembly(string sWhere)
        {
            //retorna la lista de Kits Headers

            try
            {

                Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString);

                // BM00101 - KitAssemblyHeader
                //DataSet ds = ReturnDataSet("SELECT * FROM BM00101 WHERE Bill_Status = 1 A", sWhere, "BM00101", Command.Connection);
                DataSet ds = ReturnDataSet("select b.* from BM00101 b LEFT OUTER JOIN SY03900 s ON s.NOTEINDX = b.NOTEINDX  WHERE CAST(ISNULL(TXTFIELD,'') AS VARCHAR(50)) <> 'NOTINWMS'", sWhere, "BM00101", Command.Connection);
                

                if (ds == null || ds.Tables.Count == 0)
                    return null;

                List<KitAssembly> list = new List<KitAssembly>();
                Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active });


                KitAssembly tmpData = null;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    try
                    {
                        //Map Properties
                        tmpData = new KitAssembly();

                        tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = dr["ITEMNMBR"].ToString() }); ;
                        tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup });
                        tmpData.AsmType = 2;
                        tmpData.Status = status;
                        tmpData.EfectiveDate = DateTime.Parse(dr["Effective_Date"].ToString());
                        tmpData.ObsoleteDate = DateTime.Parse(dr["Obsolete_Date"].ToString());
                        tmpData.IsFromErp = true;

                        list.Add(tmpData);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            ExceptionMngr.WriteEvent("GetKitAssembly:" + tmpData.Product.ProductCode, ListValues.EventType.Error, ex, null,
                                ListValues.ErrorCategory.ErpConnection);
                        }
                        catch { }

                        //return null;
                    }

                }

                return list;


            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetKitAssembly Connection", ListValues.EventType.Error, ex, null,
                    ListValues.ErrorCategory.ErpConnection);

                return null;
            }
        }
        private void ProcessKitAssembly(IList<KitAssembly> list, Company company)
        {
            if (list == null)
                return;

            KitAssembly curRecord = null;


            foreach (KitAssembly e in list)
            {
                try
                {

                    curRecord  =  new KitAssembly();
                    curRecord.Product = e.Product;
                    //Evalua si el elemento ya existe 
                    IList<KitAssembly> exList = Factory.DaoKitAssembly().Select(curRecord,0);

                    e.ModDate = DateTime.Now;
                    e.ModifiedBy = WmsSetupValues.SystemUser;

                    if (exList.Count == 0)
                    {
                        e.CreatedBy = WmsSetupValues.SystemUser;
                        e.CreationDate = DateTime.Now;
                        Factory.DaoKitAssembly().Save(e);
                    }
                    else
                    {
                        e.RowID = exList.First().RowID;
                        e.CreatedBy = exList.First().CreatedBy;
                        e.CreationDate = exList.First().CreationDate;
                        Factory.DaoKitAssembly().Update(e);
                    }

                    
                    //Elimna las formulas para ese producto y las crea de nuevo
                    foreach (KitAssemblyFormula kaf in Factory.DaoKitAssemblyFormula()
                        .Select(new KitAssemblyFormula { KitAssembly = new KitAssembly { Product = new Product { ProductID = e.Product.ProductID } } }))
                        Factory.DaoKitAssemblyFormula().Delete(kaf);


                    //Procesa el assembly Formula que le corresponde
                    // CAA [2010/07/19]
                    // condición busqueda kit padre
                    string query = "";
                    switch (company.ErpConnection.ConnectionType.RowID)
                    {
                        case CnnType.GPeConnect:
                            query = " ITEMNMBR = '" + e.Product.ProductCode + "' ";
                            break;
                        case CnnType.Everest:
                            query = " KIT_CODE = '" + e.Product.ProductCode + "' ";
                            break;
                        case CnnType.UnoEE:
                            query = " (formula.f134_id_cia = " + e.Product.Company.ErpCode + ") AND  itmPadre.f120_id  = '" + e.Product.ProductCode + "'";
                            break;
                        default:
                            query = "";
                            break;
                    }
                    ProcessKitAssemblyFormula(ErpFactory.References().GetKitAssemblyFormula(query));

                }
                catch (Exception ex)
                {
                    //Factory.Rollback();
                    ExceptionMngr.WriteEvent("ProcessKitAssembly:" + curRecord.Product.ProductCode, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                    //throw;
                }
            }

        }
Beispiel #13
0
 public KitAssembly GetKitAssembly(KitAssembly data)
 {
     return Factory.DaoKitAssembly().Select(data,0).First();
 }