Esempio n. 1
0
        private IList <ProductAlternate> GetAlternateProducts(Product tmpData, string item1, string item2)
        {
            IList <ProductAlternate> list = new List <ProductAlternate>();
            ProductAlternate         curAlternate;

            //Item 1
            if (!string.IsNullOrEmpty(item1))
            {
                curAlternate              = new ProductAlternate();
                curAlternate.Product      = tmpData;
                curAlternate.CreatedBy    = WmsSetupValues.SystemUser;
                curAlternate.CreationDate = DateTime.Now;
                curAlternate.IsFromErp    = true;

                try
                {
                    curAlternate.AlternProduct = WType.GetProduct(new Product {
                        ProductCode = item1, Company = CurCompany
                    });
                    list.Add(curAlternate);
                    //Console.WriteLine(curAlternate.AlternProduct.ProductCode);
                }
                catch { }
            }

            //Item 2
            if (!string.IsNullOrEmpty(item2))
            {
                curAlternate              = new ProductAlternate();
                curAlternate.Product      = tmpData;
                curAlternate.CreatedBy    = WmsSetupValues.SystemUser;
                curAlternate.CreationDate = DateTime.Now;
                curAlternate.IsFromErp    = true;

                try
                {
                    curAlternate.AlternProduct = WType.GetProduct(new Product {
                        ProductCode = item2, Company = CurCompany
                    });
                    list.Add(curAlternate);
                    //Console.WriteLine(curAlternate.AlternProduct.ProductCode);
                }
                catch { }
            }

            return(list);
        }
Esempio n. 2
0
        private IList <ProductAlternate> GetAlternateProducts(Product tmpData)
        {
            IList <ProductAlternate> list = new List <ProductAlternate>();
            ProductAlternate         curAlternate;

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

                // items equivalentes asociados al item en
                Query = "SELECT f128_rowid_item_equivalente " +
                        " FROM t128_mc_items_equivalentes WHERE f128_rowid_item = " + tmpData.Reference +
                        " AND f128_id_cia =" + CurCompany.ErpCode;

                ds = ReturnDataSet(Query, null, "t128_mc_items_equivalentes", Command.Connection);

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

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    curAlternate               = new ProductAlternate();
                    curAlternate.Product       = tmpData;
                    curAlternate.CreatedBy     = WmsSetupValues.SystemUser;
                    curAlternate.CreationDate  = DateTime.Now;
                    curAlternate.IsFromErp     = true;
                    curAlternate.AlternProduct = WType.GetProduct(new Product {
                        Reference = row["f128_rowid_item_equivalente"].ToString(), Company = CurCompany
                    });
                    list.Add(curAlternate);
                }
            }
            catch { }
            return(list);
        }
        private IList <ProductAlternate> GetAlternateProducts(Product tmpData)
        {
            IList <ProductAlternate> list = new List <ProductAlternate>();
            ProductAlternate         curAlternate;


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

            Query = GetErpQuery("ITEM_EQUIVALENCE").Replace("__ITEM", tmpData.ProductCode);

            ds = ReturnDataSet(Query, null, "ITEM_EQUIVALENCE", Command.Connection);

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

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                try
                {
                    curAlternate               = new ProductAlternate();
                    curAlternate.Product       = tmpData;
                    curAlternate.CreatedBy     = WmsSetupValues.SystemUser;
                    curAlternate.CreationDate  = DateTime.Now;
                    curAlternate.IsFromErp     = true;
                    curAlternate.AlternProduct = WType.GetProduct(new Product {
                        ProductCode = row["f128_rowid_item_equivalente"].ToString(), Company = CurCompany
                    });
                    list.Add(curAlternate);
                }
                catch { }
            }


            return(list);
        }
Esempio n. 4
0
        private IList <DocumentLine> GetReceivingDocumentLines(Document doc, Company company, DataRow[] dLines)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            //Status lineStatus = WType.GetStatus(new Status { StatusID = DocStatus.New });

            int    curLine   = 0;
            string curMaster = "";

            try
            {
                foreach (DataRow dr in dLines)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;
                    curMaster     = "";

                    tmpData.Date2       = DateTime.Parse(dr["REQDATE"].ToString());
                    tmpData.Date3       = DateTime.Parse(dr["PRMSHPDTE"].ToString());
                    tmpData.Date4       = DateTime.Parse(dr["PRMDATE"].ToString());
                    tmpData.LineNumber  = int.Parse(dr["ORD"].ToString());
                    tmpData.AccountItem = dr["VNDITNUM"].ToString();
                    tmpData.Sequence    = tmpData.LineNumber;

                    curLine              = tmpData.LineNumber;
                    tmpData.Document     = doc;
                    tmpData.IsDebit      = false;
                    tmpData.Quantity     = double.Parse(dr["QTYORDER"].ToString(), ListValues.DoubleFormat());
                    tmpData.QtyCancel    = double.Parse(dr["QTYCANCE"].ToString(), ListValues.DoubleFormat());
                    tmpData.QtyPending   = double.Parse(dr["QTYUNCMTBASE"].ToString(), ListValues.DoubleFormat());
                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster          = "Status:" + dr["POLNESTA"].ToString();
                    tmpData.LineStatus = GetReceivingStatus(int.Parse(dr["POLNESTA"].ToString())); //doc.DocStatus;
                    curMaster          = "Location:" + dr["LOCNCODE"].ToString();
                    tmpData.Location   = WType.GetLocation(new Location {
                        Company = company, ErpCode = dr["LOCNCODE"].ToString()
                    });

                    try
                    {
                        curMaster       = "Product:" + dr["ITEMNMBR"].ToString();
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = company, ProductCode = dr["ITEMNMBR"].ToString()
                        });
                        tmpData.LineDescription = dr["ITEMDESC"].ToString();

                        curMaster    = "Uom:" + dr["UOFM"].ToString();
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["UOFM"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetReceiptDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                                 ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                        continue;

                        //    //Pone el Default Product
                        //    tmpData.Product = WType.GetProduct(new Product { Company = company, ProductCode = WmsSetupValues.DEFAULT });
                        //    tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString();

                        //    curMaster = "Uom:" + dr["UOFM"].ToString();
                        //    tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() });
                    }

                    //Unit - Price, Cost
                    tmpData.UnitCost     = double.Parse(dr["UNITCOST"].ToString(), ListValues.DoubleFormat());
                    tmpData.ExtendedCost = double.Parse(dr["EXTDCOST"].ToString(), ListValues.DoubleFormat());

                    //SOP POP Link
                    object[] sop_popLink = GetSOP_POPLink(doc.DocNumber, tmpData.LineNumber, doc.DocType.DocTypeID);
                    if (sop_popLink != null)
                    {
                        tmpData.LinkDocNumber     = sop_popLink[0].ToString();
                        tmpData.LinkDocLineNumber = int.Parse(sop_popLink[1].ToString());
                    }


                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetReceiptDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
        private IList <DocumentLine> GetReceivingDocumentLines(Document doc, Company company, string docID)
        {
            DocumentLine         tmpData;
            IList <DocumentLine> list = new List <DocumentLine>();
            //Status lineStatus = WType.GetStatus(new Status { StatusID = DocStatus.New });

            int    curLine   = 0;
            string curMaster = "";

            try
            {
                Query = GetErpQuery("PURCHASEORDER_LINE").Replace("__DOCUMENT", docID);

                DataSet ds = ReturnDataSet(Query, null, "PURCHASEORDER_LINE", Command.Connection);

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



                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData       = new DocumentLine();
                    tmpData.Date1 = doc.Date1;
                    curMaster     = "";

                    try { tmpData.Date2 = DateTime.Parse(dr["f421_fecha_entrega"].ToString()); }
                    catch { }

                    //tmpData.Date3 = DateTime.Parse(dr["PRMSHPDTE"].ToString());
                    //tmpData.Date4 = DateTime.Parse(dr["PRMDATE"].ToString());
                    tmpData.LineNumber  = int.Parse(dr["f421_rowid"].ToString());
                    tmpData.AccountItem = dr["f421_cod_item_prov"].ToString();
                    tmpData.Sequence    = tmpData.LineNumber;

                    curLine          = tmpData.LineNumber;
                    tmpData.Document = doc;
                    tmpData.IsDebit  = false;
                    tmpData.Quantity = double.Parse(dr["f421_cant_pedida"].ToString(), new NumberFormatInfo {
                        NumberDecimalSeparator = Separator
                    });
                    tmpData.UnitBaseFactor = double.Parse(dr["fact_adicional"].ToString(), new NumberFormatInfo {
                        NumberDecimalSeparator = Separator
                    });


                    tmpData.CreatedBy    = WmsSetupValues.SystemUser;
                    tmpData.CreationDate = DateTime.Now;

                    curMaster          = "Status:" + dr["f421_ind_estado"].ToString();
                    tmpData.LineStatus = GetReceivingStatus(int.Parse(dr["f421_ind_estado"].ToString())); //doc.DocStatus;

                    curMaster        = "Location:" + dr["cod_bodega"].ToString();
                    tmpData.Location = WType.GetLocation(new Location {
                        Company = company, ErpCode = dr["cod_bodega"].ToString()
                    });

                    try
                    {
                        curMaster       = "Product:" + dr["f121_rowid_item"].ToString();
                        tmpData.Product = WType.GetProduct(new Product {
                            Company = company, ProductCode = dr["f121_rowid_item"].ToString()
                        });
                        tmpData.LineDescription = dr["f120_descripcion"].ToString();

                        curMaster    = "Uom:" + dr["f421_id_unidad_medida"].ToString();
                        tmpData.Unit = WType.GetUnit(new Unit {
                            ErpCode = dr["f421_id_unidad_medida"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup
                        });
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetReceiptDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                                 ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                        continue;

                        //    //Pone el Default Product
                        //    tmpData.Product = WType.GetProduct(new Product { Company = company, ProductCode = WmsSetupValues.DEFAULT });
                        //    tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString();

                        //    curMaster = "Uom:" + dr["UOFM"].ToString();
                        //    tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() });
                    }

                    //Unit - Price, Cost
                    tmpData.UnitPrice = double.Parse(dr["f421_precio_unitario"].ToString(), new NumberFormatInfo {
                        NumberDecimalSeparator = Separator
                    });
                    tmpData.ExtendedPrice = double.Parse(dr["subtotal"].ToString(), new NumberFormatInfo {
                        NumberDecimalSeparator = Separator
                    });

                    //SOP POP Link
                    //object[] sop_popLink = GetSOP_POPLink(doc.DocNumber, tmpData.LineNumber, doc.DocType.DocTypeID);
                    //if (sop_popLink != null)
                    //{
                    //    tmpData.LinkDocNumber = sop_popLink[0].ToString();
                    //    tmpData.LinkDocLineNumber = int.Parse(sop_popLink[1].ToString());
                    //}


                    list.Add(tmpData);
                }

                return((list.Count > 0) ? list : null);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetReceiptDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster,
                                         ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }