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); } }
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); } }