예제 #1
0
        public IList<AccountAddress> Select(AccountAddress data)
        {

                IList<AccountAddress> datos = new List<AccountAddress>();
                datos = GetHsql(data).List<AccountAddress>();
                if (!Factory.IsTransactional)
                    Factory.Commit();
                return datos;
           
        }
예제 #2
0
        public override Boolean Equals(object obj)
        {
            if ((obj == null) || (obj.GetType() != this.GetType()))
            {
                return(false);
            }
            AccountAddress castObj = (AccountAddress)obj;

            return((castObj != null) &&
                   (this.AddressID == castObj.AddressID));
        }
 public string CreateCustomerAddress(AccountAddress address)
 {
     throw new NotImplementedException();
 }
        private DocumentAddress GetBillAddress(Document doc, string addressCode, string customerCode, short AccnType)
        {
            DocumentAddress billAddress = null;

            AccountAddress accountAddress = new AccountAddress
            {
                Account = new Account { AccountCode = customerCode, BaseType = new AccountType { AccountTypeID = AccnType } },
                ErpCode = addressCode
            };

            accountAddress = WType.GetAccountAddress(accountAddress);

            if (accountAddress != null)
            {
                billAddress = new DocumentAddress();
                billAddress.Document = doc;
                billAddress.DocumentLine = null;
                billAddress.Name = accountAddress.Name;
                billAddress.AddressLine1 = accountAddress.AddressLine1;
                billAddress.AddressLine2 = accountAddress.AddressLine2;
                billAddress.AddressLine3 = accountAddress.AddressLine3;
                billAddress.City = accountAddress.City;
                billAddress.State = accountAddress.State;
                billAddress.ZipCode = accountAddress.ZipCode;
                billAddress.Country = accountAddress.Country;
                billAddress.Phone1 = accountAddress.Phone1;
                billAddress.Phone2 = accountAddress.Phone2;
                billAddress.Phone3 = accountAddress.Phone3;
                billAddress.ContactPerson = accountAddress.ContactPerson;
                billAddress.AddressType = AddressType.Billing;
                billAddress.Email = accountAddress.Email;
                billAddress.CreationDate = DateTime.Now;
                billAddress.CreatedBy = WmsSetupValues.SystemUser;
                billAddress.ErpCode = addressCode;
            }

            return billAddress;      
        }
예제 #5
0
        public string CreateCustomerAddress(AccountAddress address)
        {
            SetConnectMngr(address.Account.Company);

            return ErpFactory.Documents().CreateCustomerAddress(address);
        }
예제 #6
0
        private IList<AccountAddress> GetCustomerAddress(Account account, string personId)
        {

            AccountAddress tmpData;
            IList<AccountAddress> list = new List<AccountAddress>();
            Status lineStatus = WType.GetStatus(new Status { StatusID = EntityStatus.Active });

            try
            {

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

                Query = "select cli.f201_id_sucursal, cli.f201_descripcion_sucursal, c.f015_direccion1, c.f015_direccion2, c.f015_direccion3, c.f015_telefono, " +
                        " c.f015_cod_postal, c.f015_email, p.f011_descripcion pais, d.f012_descripcion dpto, city.f013_descripcion city " +
                        "   from t201_mm_clientes cli JOIN dbo.t015_mm_contactos c ON cli.f201_rowid_contacto = c.f015_rowid " +
                        "     LEFT OUTER JOIN dbo.t011_mm_paises p ON c.f015_id_pais = p.f011_id " +
                        "     LEFT OUTER JOIN dbo.t012_mm_deptos d ON c.f015_id_depto = d.f012_id AND c.f015_id_pais = d.f012_id_pais " +
                        "     LEFT OUTER JOIN dbo.t013_mm_ciudades city ON c.f015_id_ciudad = city.f013_id AND c.f015_id_pais = city.f013_id_pais AND c.f015_id_depto = city.f013_id_depto " +
                        "   where cli.f201_rowid_tercero= " + personId + " AND cli.f201_id_cia = " + CurCompany.ErpCode + " AND c.f015_id_cia = " + CurCompany.ErpCode;

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

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

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData = new AccountAddress();
                    tmpData.Account = account;
                    tmpData.Name = dr["f201_id_sucursal"].ToString();
                    tmpData.ErpCode = dr["f201_id_sucursal"].ToString();
                    tmpData.AddressLine1 = dr["f015_direccion1"].ToString();
                    tmpData.AddressLine2 = dr["f015_direccion2"].ToString();
                    tmpData.AddressLine3 = dr["f015_direccion3"].ToString();
                    tmpData.City = dr["city"].ToString();
                    tmpData.State = dr["dpto"].ToString();
                    tmpData.ZipCode = dr["f015_cod_postal"].ToString();
                    tmpData.Country = dr["pais"].ToString();
                    tmpData.Phone1 = dr["f015_telefono"].ToString();
                    //tmpData.Phone2 = dr["PHNUMBR2"].ToString();
                    //tmpData.Phone3 = dr["FAXNUMBR"].ToString();
                    tmpData.Email = dr["f015_email"].ToString();
                    tmpData.Status = lineStatus;
                    tmpData.IsMain = false;
                    tmpData.ContactPerson = account.ContactPerson;
                    tmpData.CreationDate = DateTime.Now;
                    tmpData.CreatedBy = WmsSetupValues.SystemUser;
                    tmpData.IsFromErp = true;

                    list.Add(tmpData);
                }

                return list;
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetCustomerAddress", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return null;
            }
        }
예제 #7
0
 public String CreateCustomerAddress(AccountAddress address)
 {
     return ErpMngr.CreateCustomerAddress(address);
 }
예제 #8
0
 public void UpdateAccountAddress(AccountAddress data)
 {
      BasicMngr.SaveUpdateAccountAddres(data, 2); //2 Update
 }
예제 #9
0
 public Boolean Delete(AccountAddress data)
 {
     return base.Delete(data);
 }
예제 #10
0
 public Boolean Update(AccountAddress data)
 {
     return base.Update(data);
 }
예제 #11
0
 public AccountAddress Save(AccountAddress data)
 {
     return (AccountAddress)base.Save(data);
 }
예제 #12
0
        private void ProcessErpAccounts(IList<Account> list)
        {

            if (list == null)
                return;


            DaoFactory Factory = new DaoFactory();

            Account qAcc = null;
            AccountAddress curLine;
            AccountTypeRelation curAccType;


            foreach (Account e in list)
            {
                try
                {


                    qAcc = new Account();
                    qAcc.Company = e.Company;
                    qAcc.AccountCode = e.AccountCode;
                    qAcc.BaseType = e.BaseType;

                    //Evalua si la entidad ya existe 
                    IList<Account> exList = Factory.DaoAccount().Select(qAcc);
                    e.ModDate = DateTime.Now;
                    e.ModifiedBy = WmsSetupValues.SystemUser;

                    //Si existe
                    if (exList.Count == 0)
                    {
                        e.CreationDate = DateTime.Now;
                        e.CreatedBy = WmsSetupValues.SystemUser;
                        Factory.DaoAccount().Save(e);
                    }
                    else
                    {
                        e.AccountID = exList.First().AccountID;
                        e.CreatedBy = exList.First().CreatedBy;
                        e.CreationDate = exList.First().CreationDate;

                        //Preservar
                        e.UserDefine1 = exList.First().UserDefine1; //Shipping Mails


                        //Evaluar los Account Types
                        int i = 0;
                        foreach (AccountTypeRelation line in e.AccountTypes)
                        {
                            curAccType = new AccountTypeRelation();
                            curAccType.Account = e;
                            curAccType.ErpCode = line.ErpCode;
                            curAccType.AccountType = line.AccountType;
                            IList<AccountTypeRelation> listLines = Factory.DaoAccountTypeRelation().Select(curAccType);

                            if (listLines.Count > 0)
                            {
                                e.AccountTypes[i].ModDate = DateTime.Now;
                                e.AccountTypes[i].ModifiedBy = WmsSetupValues.SystemUser;
                                e.AccountTypes[i].CreationDate = listLines.First().CreationDate;
                                e.AccountTypes[i].CreatedBy = listLines.First().CreatedBy;
                                e.AccountTypes[i].RowID = listLines.First().RowID;
                            }
                            else
                            {
                                e.AccountTypes[i].CreationDate = DateTime.Now;
                                e.AccountTypes[i].CreatedBy = WmsSetupValues.SystemUser;
                            }

                            i++;
                        }


                        //Evaluar los document Lines
                        i = 0;
                        foreach (AccountAddress line in e.AccountAddresses)
                        {
                            curLine = new AccountAddress();
                            curLine.Account = e;
                            curLine.ErpCode = line.ErpCode;
                            IList<AccountAddress> listLines = Factory.DaoAccountAddress().Select(curLine);

                            if (listLines.Count > 0)
                            {
                                e.AccountAddresses[i].ModDate = DateTime.Now;
                                e.AccountAddresses[i].ModifiedBy = WmsSetupValues.SystemUser;
                                e.AccountAddresses[i].AddressID = listLines.First().AddressID;
                                e.AccountAddresses[i].CreationDate = listLines.First().CreationDate;
                                e.AccountAddresses[i].CreatedBy = listLines.First().CreatedBy;
                            }
                            else
                            {
                                e.AccountAddresses[i].CreationDate = DateTime.Now;
                                e.AccountAddresses[i].CreatedBy = WmsSetupValues.SystemUser;
                            }

                            i++;
                        }

                        Factory.DaoAccount().Update(e);
                    }

                }
                catch (Exception ex)
                {
                    Factory.Rollback();
                    ExceptionMngr.WriteEvent("ProcessErpAccounts:" + qAcc.Name, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                    ////throw;
                }
            }


        }
예제 #13
0
 public AccountAddress GetAccountAddress(AccountAddress data)
 {
     return Factory.DaoAccountAddress().Select(data).FirstOrDefault();
 }
예제 #14
0
 public string CreateCustomerAddress(Entities.Master.AccountAddress address)
 {
     throw new NotImplementedException();
 }
        public string CreateCustomerAddress(AccountAddress address)  // string path
        {
            try
            {
                // datos de la address
                taCreateCustomerAddress_ItemsTaCreateCustomerAddress add = new taCreateCustomerAddress_ItemsTaCreateCustomerAddress();
                
                add.CUSTNMBR = address.Account.AccountCode;
                add.ADRSCODE = address.ErpCode;
                add.ADDRESS1 = address.AddressLine1;
                add.ADDRESS2 = address.AddressLine2;
                add.ADDRESS3 = address.AddressLine3;
                add.CNTCPRSN = address.ContactPerson;
                add.PHNUMBR1 = address.Phone1;
                add.PHNUMBR2 = address.Phone2;
                add.PHNUMBR3 = address.Phone3;
                add.COUNTRY = address.Country;
                add.STATE = address.State;
                add.CITY = address.City;
                add.ZIPCODE = address.ZipCode;
                add.UpdateIfExists = 1;  //Update If Exists

                RMCustomerAddressType addType = new RMCustomerAddressType();
                addType.taCreateCustomerAddress_Items = new taCreateCustomerAddress_ItemsTaCreateCustomerAddress[] { add };

                RMCustomerAddressType[] arrAddTypes = { addType };

                //Create an eConnect XML document object and populate 
                eConnectType eConnect = new eConnectType();
                eConnect.RMCustomerAddressType = arrAddTypes;

                //Serialize the XML document to the file
                XmlSerializer serializer = new XmlSerializer(typeof(eConnectType));
                StringWriter writer = new StringWriter();
                serializer.Serialize(writer, eConnect);

                DynamicsGP_ec.SendData(writer.ToString()); 
                
                return address.Account.AccountCode;

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

            
        }
예제 #16
0
 public IList<AccountAddress> GetAccountAddress(AccountAddress data) { return Factory.DaoAccountAddress().Select(data); }
예제 #17
0
 public AccountAddress SaveAccountAddress(AccountAddress data) {
     return BasicMngr.SaveUpdateAccountAddres(data, 1); //1 Save
 }
예제 #18
0
 public AccountAddress SelectById(AccountAddress data)
 {
     return (AccountAddress)base.SelectById(data);
 }
예제 #19
0
 public void DeleteAccountAddress(AccountAddress data) { Factory.DaoAccountAddress().Delete(data); }
예제 #20
0
        private IList<AccountAddress> GetCustomerAddress(Account account, DataRow[] dLines) {
            
            AccountAddress tmpData;
            IList<AccountAddress> list = new List<AccountAddress>();
            Status lineStatus = WType.GetStatus(new Status { StatusID = EntityStatus.Active });

            try
            {

                foreach (DataRow dr in dLines)
                {
                    tmpData = new AccountAddress();
                    tmpData.Account = account;
                    tmpData.Name = dr["ADRSCODE"].ToString(); //dr["CNTCPRSN"].ToString();
                    tmpData.ErpCode = dr["ADRSCODE"].ToString();
                    tmpData.AddressLine1 = dr["ADDRESS1"].ToString();
                    tmpData.AddressLine2 = dr["ADDRESS2"].ToString();
                    tmpData.AddressLine3 = dr["ADDRESS3"].ToString();
                    tmpData.City = dr["CITY"].ToString();
                    tmpData.State = dr["STATE"].ToString();
                    tmpData.ZipCode = dr["ZIP"].ToString();
                    tmpData.Country = dr["COUNTRY"].ToString();
                    tmpData.Phone1 = dr["PHONE1"].ToString();
                    tmpData.Phone2 = dr["PHONE2"].ToString();
                    tmpData.Phone3 = dr["FAX"].ToString();
                    try { tmpData.Email = dr["Internet_Address"].ToString(); }
                    catch { }
                    tmpData.Status = lineStatus;
                    tmpData.IsMain = false;
                    tmpData.ContactPerson = dr["CNTCPRSN"].ToString(); 
                    tmpData.CreationDate = DateTime.Now;
                    tmpData.CreatedBy = WmsSetupValues.SystemUser;
                    tmpData.IsFromErp = true;

                    list.Add(tmpData);
                }

                return list;
            }
            catch (Exception ex)
            {
                ExceptionMngr.WriteEvent("GetCustomerAddress", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection);
                //throw;
                return null; 
            }
        }
예제 #21
0
        public AccountAddress SaveUpdateAccountAddres(AccountAddress data, int saveType)
        {

            //Save in the ERP
            if (GetCompanyOption(data.Account.Company, "WITHERPSH").Equals("T"))
            {
                if (saveType == 1)
                {                    
                    data.ErpCode = data.Name.Replace("'", "").Replace(" ", "");

                    if (data.ErpCode.Length > 10)
                        data.ErpCode = data.ErpCode.Substring(0, 10);                                            
                }

                (new ErpDataMngr()).CreateCustomerAddress(data);
            }
            

            if (saveType == 1)
                data = Factory.DaoAccountAddress().Save(data);
            else
                Factory.DaoAccountAddress().Update(data);


            return data;
            
        }
예제 #22
0
        private IList<AccountAddress> GetCustomerAddress(Account account, string personId)
        {

            AccountAddress tmpData;
            IList<AccountAddress> list = new List<AccountAddress>();
            Status lineStatus = WType.GetStatus(new Status { StatusID = EntityStatus.Active });

            try
            {

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

                Query = GetErpQuery("CUSTOMER_ADDRESS").Replace("__ACCOUNT", personId);

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

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

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    tmpData = new AccountAddress();
                    tmpData.Account = account;
                    tmpData.Name = dr["f201_descripcion_sucursal"].ToString();
                    tmpData.ErpCode = dr["f201_id_sucursal"].ToString();
                    tmpData.AddressLine1 = dr["f015_direccion1"].ToString();
                    tmpData.AddressLine2 = dr["f015_direccion2"].ToString();
                    tmpData.AddressLine3 = dr["f015_direccion3"].ToString();
                    tmpData.City = dr["city"].ToString();
                    tmpData.State = dr["dpto"].ToString();
                    tmpData.ZipCode = dr["f015_cod_postal"].ToString();
                    tmpData.Country = dr["pais"].ToString();
                    tmpData.Phone1 = dr["f015_telefono"].ToString();
                    //tmpData.Phone2 = dr["PHNUMBR2"].ToString();
                    //tmpData.Phone3 = dr["FAXNUMBR"].ToString();
                    tmpData.Email = dr["f015_email"].ToString();
                    tmpData.Status = lineStatus;
                    tmpData.IsMain = false;
                    tmpData.ContactPerson = account.ContactPerson;
                    tmpData.CreationDate = DateTime.Now;
                    tmpData.CreatedBy = WmsSetupValues.SystemUser;
                    tmpData.IsFromErp = true;

                    list.Add(tmpData);
                }

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