コード例 #1
0
        private IList <ProductAccountRelation> GetProductVendors(Product product)
        {
            IList <ProductAccountRelation> productVendor = new List <ProductAccountRelation>();
            ProductAccountRelation         curId         = null;
            AccountType accType = WType.GetAccountType(new AccountType {
                AccountTypeID = 2
            });

            string curItemVendor = "";

            try
            {
                //Ask for the vendor Item record
                string sWhere = " ITEMNMBR = '" + product.ProductCode + "'";
                ds = DynamicsGP_ec.GetDataSet(DynamicsGP_ec.RetreiveData("VendorItem", false, 2, 0, sWhere, true));

                if (ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[1].Rows)
                    {
                        curId = new ProductAccountRelation();

                        curId.ItemNumber = dr["VNDITNUM"].ToString();

                        //Si esta vacio se sale al proximo
                        if (string.IsNullOrEmpty(curId.ItemNumber))
                        {
                            continue;
                        }

                        curItemVendor = dr["VENDORID"].ToString() + ":" + curId.ItemNumber;

                        curId.IsFromErp   = true;
                        curId.AccountType = accType;
                        curId.Account     = WType.GetAccount(new Account {
                            AccountCode = dr["VENDORID"].ToString(), BaseType = new AccountType {
                                AccountTypeID = AccntType.Vendor
                            }
                        });
                        curId.Product      = product;
                        curId.CreatedBy    = WmsSetupValues.SystemUser;
                        curId.CreationDate = DateTime.Now;

                        productVendor.Add(curId);
                    }
                }

                return(productVendor);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetProductVendors:" + curItemVendor, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
コード例 #2
0
        private IList <ProductAccountRelation> GetProductVendors(Product product)
        {
            IList <ProductAccountRelation> productVendor = new List <ProductAccountRelation>();
            ProductAccountRelation         curId         = null;
            AccountType accType = WType.GetAccountType(new AccountType {
                AccountTypeID = AccntType.Vendor
            });

            string curItemVendor = "";

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

                Query = "SELECT VEND_CODE,VENDOR_PART_NO " +
                        " FROM ITEM_REPLENISH_VENDOR WHERE ITEM_CODE = '" + product.ProductCode + "' ";

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

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

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    curId = new ProductAccountRelation();

                    curId.ItemNumber = dr["VENDOR_PART_NO"].ToString();

                    //Si esta vacio se sale al proximo
                    if (string.IsNullOrEmpty(curId.ItemNumber))
                    {
                        continue;
                    }

                    curItemVendor = dr["VEND_CODE"].ToString() + ":" + curId.ItemNumber;

                    curId.IsFromErp   = true;
                    curId.AccountType = accType;
                    curId.Account     = WType.GetAccount(new Account {
                        AccountCode = dr["VEND_CODE"].ToString(), BaseType = new AccountType {
                            AccountTypeID = AccntType.Vendor
                        }
                    });
                    curId.Product      = product;
                    curId.CreatedBy    = WmsSetupValues.SystemUser;
                    curId.CreationDate = DateTime.Now;

                    productVendor.Add(curId);
                }


                return(productVendor);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetProductVendors:" + curItemVendor, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }
コード例 #3
0
        private IList <Account> GetVendors(string sWhere)
        {
            IList <Account>     list = new List <Account>();
            Account             tmpData;
            AccountTypeRelation tmpAccTypeRel;

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

                Query = GetErpQuery("VENDORS");

                ds = ReturnDataSet(Query, sWhere, "VENDORS", Command.Connection);

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


                //Company company = WType.GetDefaultCompany();
                AccountType accType = WType.GetAccountType(new AccountType {
                    AccountTypeID = AccntType.Vendor
                });
                Status status = WType.GetStatus(new Status {
                    StatusID = EntityStatus.Active
                });

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


                    try
                    {
                        tmpData.AccountCode = dr["f200_id"].ToString();
                        if (string.IsNullOrEmpty(tmpData.AccountCode))
                        {
                            continue;
                        }

                        tmpData.Company       = CurCompany;
                        tmpData.ContactPerson = dr["f015_contacto"].ToString();


                        tmpData.Name = dr["f200_razon_social"].ToString();
                        //tmpData.Phone = dr["PHNUMBR1"].ToString();
                        tmpData.UserDefine1 = dr["f200_nit"].ToString();
                        tmpData.UserDefine2 = dr["f202_id_sucursal"].ToString();

                        //Account Type
                        tmpAccTypeRel              = new AccountTypeRelation();
                        tmpAccTypeRel.Account      = tmpData;
                        tmpAccTypeRel.AccountType  = accType;
                        tmpAccTypeRel.ErpCode      = dr["f200_rowid"].ToString();
                        tmpAccTypeRel.Status       = status;
                        tmpAccTypeRel.CreationDate = DateTime.Now;
                        tmpAccTypeRel.CreatedBy    = WmsSetupValues.SystemUser;
                        tmpData.AccountTypes       = new AccountTypeRelation[] { tmpAccTypeRel };
                        tmpData.IsFromErp          = true;
                        tmpData.BaseType           = accType;

                        //Asignacion de Lines.... Datos del contacto del vendor (proveedor)
                        tmpData.AccountAddresses = GetVendorAddress(tmpData, dr["f200_rowid"].ToString());

                        list.Add(tmpData);
                    }
                    catch (Exception ex)
                    {
                        ExceptionMngr.WriteEvent("GetVendors:" + tmpData.AccountCode + "-" +
                                                 tmpData.Name, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                    }
                }

                //retornar la lista
                return(list);
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetVendors", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return(null);
            }
        }