コード例 #1
0
        public IList <KitAssemblyFormula> Select(KitAssemblyFormula data)
        {
            IList <KitAssemblyFormula> datos = new List <KitAssemblyFormula>();

            datos = GetHsql(data).List <KitAssemblyFormula>();
            if (!Factory.IsTransactional)
            {
                Factory.Commit();
            }
            return(datos);
        }
コード例 #2
0
        private void OnSaveComponent(object sender, EventArgs e)
        {
            string message = "";

            if (View.TxtComponent.Product.ProductID == 0 || string.IsNullOrEmpty(View.TxtQty.Text) || string.IsNullOrEmpty(View.TxtOrder.Text))
            {
                Util.ShowError("Product, Quantity and Order are required.");
                return;
            }
            else  // valida que ya no exista como componente del KIT.
            {
                // if (View.Model.Record.ProductFormula.Where(f => f.Component.ProductID == View.TxtComponent.Product.ProductID).Count() >0)
                if (service.GetKitAssemblyFormula(new KitAssemblyFormula
                {
                    KitAssembly = new KitAssembly {
                        Product = View.Model.Record.Product
                    }
                }).Where(f => f.Component.ProductID == View.TxtComponent.Product.ProductID).Count() > 0)
                {
                    Util.ShowError("Component is already in the kit.");
                    return;
                }
            }

            try
            {
                KitAssemblyFormula kaf = new KitAssemblyFormula();
                kaf.KitAssembly   = View.Model.Record;
                kaf.Component     = View.TxtComponent.Product;
                kaf.DirectProduct = View.Model.Record.Product;
                kaf.Unit          = View.TxtComponent.Product.BaseUnit;
                kaf.Ord           = int.Parse(View.TxtOrder.Text);
                kaf.Status        = new Status {
                    StatusID = EntityStatus.Active
                };
                kaf.FormulaQty   = float.Parse(View.TxtQty.Text);
                kaf.ScrapPercent = 0;
                kaf.EfectiveDate = DateTime.Now;
                kaf.ObsoleteDate = DateTime.Now;
                kaf.CreationDate = DateTime.Now;
                kaf.CreatedBy    = App.curUser.UserName;

                message = "Record created.";
                View.Model.FormulaList.Add(service.SaveKitAssemblyFormula(kaf));
                // View.Model.Record.ProductFormula.Add
                View.LvFormula.Items.Refresh();
                CleanComponentSection();

                Util.ShowMessage(message);
            }
            catch (Exception ex) { Util.ShowError(ex.Message); }
        }
コード例 #3
0
        private void ProcessKitAssemblyFormula(IList <KitAssemblyFormula> list)
        {
            if (list == null)
            {
                return;
            }

            KitAssemblyFormula curRecord = null;


            foreach (KitAssemblyFormula e in list)
            {
                try
                {
                    curRecord = e;
                    //Evalua si el elemento ya existe
                    IList <KitAssemblyFormula> exList = Factory.DaoKitAssemblyFormula().Select(e);

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

                    if (exList.Count == 0)
                    {
                        e.CreatedBy    = WmsSetupValues.SystemUser;
                        e.CreationDate = DateTime.Now;
                        Factory.DaoKitAssemblyFormula().Save(e);
                    }
                    else
                    {
                        e.RowID        = exList.First().RowID;
                        e.CreatedBy    = exList.First().CreatedBy;
                        e.CreationDate = exList.First().CreationDate;
                        Factory.DaoKitAssemblyFormula().Update(e);
                    }
                }
                catch (Exception ex)
                {
                    Factory.Rollback();
                    ExceptionMngr.WriteEvent("ProcessKitAssemblyFormula:" + curRecord.KitAssembly.Product.ProductCode, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                    //throw;
                }
            }
        }
コード例 #4
0
        public override IQuery GetHsql(Object data)
        {
            StringBuilder      sql    = new StringBuilder("select a from KitAssemblyFormula a   where  ");
            KitAssemblyFormula kitasm = (KitAssemblyFormula)data;

            if (kitasm != null)
            {
                Parms = new List <Object[]>();
                if (kitasm.RowID != 0)
                {
                    sql.Append(" a.RowID = :id     and   ");
                    Parms.Add(new Object[] { "id", kitasm.RowID });
                }

                if (kitasm.KitAssembly != null)
                {
                    if (kitasm.KitAssembly.RowID != 0)
                    {
                        sql.Append(" a.KitAssembly.RowID = :id1     and   ");
                        Parms.Add(new Object[] { "id1", kitasm.KitAssembly.RowID });
                    }

                    if (kitasm.KitAssembly.Product != null && kitasm.KitAssembly.Product.ProductID != 0)
                    {
                        sql.Append(" a.KitAssembly.Product.ProductID = :idp1     and   ");
                        Parms.Add(new Object[] { "idp1", kitasm.KitAssembly.Product.ProductID });
                    }

                    if (kitasm.KitAssembly.Product != null && !string.IsNullOrEmpty(kitasm.KitAssembly.Product.ProductCode))
                    {
                        sql.Append(" a.KitAssembly.Product.ProductCode = :idpc     and   ");
                        Parms.Add(new Object[] { "idpc", kitasm.KitAssembly.Product.ProductCode });
                    }
                }

                if (kitasm.DirectProduct != null)
                {
                    if (kitasm.DirectProduct.ProductID != 0)
                    {
                        sql.Append(" a.DirectProduct.ProductID = :ipz1     and   ");
                        Parms.Add(new Object[] { "ipz1", kitasm.DirectProduct.ProductID });
                    }

                    if (kitasm.DirectProduct.Category != null && kitasm.DirectProduct.Category.ExplodeKit != 0)
                    {
                        sql.Append(" a.DirectProduct.Category.ExplodeKit = :ih1     and   ");
                        Parms.Add(new Object[] { "ih1", kitasm.DirectProduct.Category.ExplodeKit });
                    }
                }


                if (kitasm.Component != null && kitasm.Component.ProductID != 0)
                {
                    sql.Append(" a.Component.ProductID = :id2     and   ");
                    Parms.Add(new Object[] { "id2", kitasm.Component.ProductID });
                }


                if (kitasm.Status != null && kitasm.Status.StatusID != 0)
                {
                    sql.Append(" a.Status.StatusID = :id3     and   ");
                    Parms.Add(new Object[] { "id3", kitasm.Status.StatusID });
                }


                if (kitasm.Unit != null && kitasm.Unit.UnitID != 0)
                {
                    sql.Append(" a.Unit.UnitID = :id4     and   ");
                    Parms.Add(new Object[] { "id4", kitasm.Unit.UnitID });
                }

                if (kitasm.ObsoleteDate != null)
                {
                    sql.Append(" a.ObsoleteDate = :id5     and   ");
                    Parms.Add(new Object[] { "id5", kitasm.ObsoleteDate });
                }


                if (kitasm.EfectiveDate != null)
                {
                    sql.Append(" a.EfectiveDate = :id6    and   ");
                    Parms.Add(new Object[] { "id6", kitasm.EfectiveDate });
                }
            }

            sql = new StringBuilder(sql.ToString());
            sql.Append(" 1=1 order by a.RowID asc ");
            IQuery query = Factory.Session.CreateQuery(sql.ToString());

            SetParameters(query);
            return(query);
        }
コード例 #5
0
 public KitAssemblyFormula SelectById(KitAssemblyFormula data)
 {
     return((KitAssemblyFormula)base.SelectById(data));
 }
コード例 #6
0
 public Boolean Delete(KitAssemblyFormula data)
 {
     return(base.Delete(data));
 }
コード例 #7
0
 public Boolean Update(KitAssemblyFormula data)
 {
     return(base.Update(data));
 }
コード例 #8
0
 public KitAssemblyFormula Save(KitAssemblyFormula data)
 {
     return((KitAssemblyFormula)base.Save(data));
 }
コード例 #9
0
 public void DeleteKitAssemblyFormula(KitAssemblyFormula data)
 {
     try
     {
         SetService(); SerClient.DeleteKitAssemblyFormula(data);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
コード例 #10
0
 public KitAssemblyFormula SaveKitAssemblyFormula(KitAssemblyFormula data)
 {
     try
     {
         SetService(); return SerClient.SaveKitAssemblyFormula(data);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
コード例 #11
0
        public IList <KitAssemblyFormula> GetKitAssemblyFormula(string sWhere)
        {
            //retorna la lista de Formulas.

            KitAssemblyFormula tmpData = null;

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

                // BM00101 - KitAssemblyHeader
                DataSet ds = ReturnDataSet("SELECT * FROM BM00111 WHERE Bill_Status = 1 AND Component_Status=1 ", sWhere, "BM00111", Command.Connection);


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


                List <KitAssemblyFormula> list = new List <KitAssemblyFormula>();
                Status statusOK = WType.GetStatus(new Status {
                    StatusID = EntityStatus.Active
                });
                Status statusInactive = WType.GetStatus(new Status {
                    StatusID = EntityStatus.Inactive
                });

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

                        tmpData.KitAssembly = WType.GetKitAssembly(new KitAssembly {
                            Product = new Product {
                                Company = CurCompany, ProductCode = dr["ITEMNMBR"].ToString()
                            }
                        });
                        tmpData.Status       = (dr["Component_Status"].ToString() == "1") ? statusOK : statusInactive;
                        tmpData.EfectiveDate = DateTime.Parse(dr["Effective_Date"].ToString());
                        tmpData.ObsoleteDate = DateTime.Parse(dr["Obsolete_Date"].ToString());
                        tmpData.Component    = WType.GetProduct(new Product {
                            Company = CurCompany, ProductCode = dr["CMPTITNM"].ToString()
                        });
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["UOFM"].ToString(), ErpCodeGroup = tmpData.Component.BaseUnit.ErpCodeGroup
                        });
                        tmpData.FormulaQty    = Double.Parse(dr["Design_Qty"].ToString());;
                        tmpData.Ord           = int.Parse(dr["ORD"].ToString());;
                        tmpData.ScrapPercent  = Double.Parse(dr["Scrap_Percentage"].ToString());
                        tmpData.DirectProduct = WType.GetProduct(new Product {
                            Company = CurCompany, ProductCode = dr["ITEMNMBR"].ToString()
                        });

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

                        return(null);
                    }
                }


                return(list);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetKitAssemblyFormula:", ListValues.EventType.Error, ex, null,
                                         ListValues.ErrorCategory.ErpConnection);

                return(null);
            }
        }
コード例 #12
0
        public IList <KitAssemblyFormula> GetKitAssemblyFormula(string sWhere)
        {
            //retorna la lista de Formulas.

            KitAssemblyFormula tmpData = null;

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

                Query = "select KIT_CODE, ITEM_CODE, ITEM_QTY 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 <KitAssemblyFormula> list = new List <KitAssemblyFormula>();
                Status statusOK = WType.GetStatus(new Status {
                    StatusID = EntityStatus.Active
                });
                Status statusInactive = WType.GetStatus(new Status {
                    StatusID = EntityStatus.Inactive
                });

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

                        tmpData.KitAssembly = WType.GetKitAssembly(new KitAssembly {
                            Product = new Product {
                                Company = CurCompany, ProductCode = dr["KIT_CODE"].ToString()
                            }
                        });
                        tmpData.Status       = statusOK;
                        tmpData.EfectiveDate = DateTime.Now;
                        tmpData.ObsoleteDate = DateTime.Now;
                        tmpData.Component    = WType.GetProduct(new Product {
                            Company = CurCompany, ProductCode = dr["ITEM_CODE"].ToString()
                        });
                        tmpData.Unit          = tmpData.Component.BaseUnit;
                        tmpData.FormulaQty    = Double.Parse(dr["ITEM_QTY"].ToString());;
                        tmpData.Ord           = 1;
                        tmpData.ScrapPercent  = 0;
                        tmpData.DirectProduct = WType.GetProduct(new Product {
                            Company = CurCompany, ProductCode = dr["KIT_CODE"].ToString()
                        });

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

                        return(null);
                    }
                }


                return(list);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetKitAssemblyFormula:", ListValues.EventType.Error, ex, null,
                                         ListValues.ErrorCategory.ErpConnection);

                return(null);
            }
        }