private void SetCustAddrDefaultSettings(ref CustAddress custAddr) { custAddr.AllowInvtSubst = 1; custAddr.BackOrdPrice = 0; custAddr.BOLReqd = 0; custAddr.CarrierAcctNo = ""; custAddr.CarrierBillMeth = 6; //default custAddr.CloseSOLineOnFirstShip = 0; custAddr.CloseSOOnFirstShip = 0; custAddr.CreateDate = DateTime.Now; custAddr.CreateType = 0; custAddr.CreateUserID = Environment.UserName; custAddr.FreightMethod = 2; //default custAddr.InvcMsg = ""; custAddr.InvoiceReqd = 0; custAddr.InvcFormKey = 79; //printed invoices by default custAddr.PackListContentsReqd = 0; custAddr.PackListFormKey = 84; custAddr.PackListReqd = 0; custAddr.PriceAdj = 0; custAddr.PriceBase = 0; custAddr.PrintOrderAck = 0; custAddr.ShipDays = 3; //default custAddr.ShipLabelsReqd = 0; custAddr.SOAckMeth = 0; custAddr.UsePromoPrice = 0; }
public void AddCustAddress(CustAddress custAddress) { custAddress.Address.Key = _addressRepository.GetSurrogateKey(); custAddress.Key = custAddress.Address.Key; custAddress.CustAddrID = custAddress.Key.ToString(); _custAddressRepository.Add(custAddress); }
private void AddressPage_Done(BLAddress address) { btnNext.Enabled = true; newCustomer.Id = address.CustId; newCustomer.Name = address.Data.Name; newCustomer.PrimaryAddress.Name = address.Data.Name; newCustomer.PrimaryAddress.Line1 = address.Data.Line1; newCustomer.PrimaryAddress.Line2 = address.Data.Line2; newCustomer.PrimaryAddress.City = address.Data.City; newCustomer.PrimaryAddress.State = address.Data.State; newCustomer.PrimaryAddress.Zip = address.Data.Zip; newCustomer.PrimaryAddress.Country = address.Data.Country; newCustomer.PrimaryAddress.Residential = address.Data.Residential; var primaryCustAddr = newCustomer.CustAddresses.FirstOrDefault(c => c.Type == CustAddrType.Primary); if (primaryCustAddr == null) { primaryCustAddr = new CustAddress { Type = CustAddrType.Primary }; newCustomer.CustAddresses.Add(primaryCustAddr); } primaryCustAddr.STaxSchdKey = address.SalesTaxKey; primaryIsGov = address.IsGovernment; }
private void SetCurrentAddressFromSelectedRow() { var currentList = GetCurrentList(); currentAddress = currentList.FirstOrDefault(c => c.Data.Key == cachedAddrKeyForRowSelection); if (currentAddress == null) { if (currentList.Count == 0) { currentAddress = new BLAddress(); currentAddress.Data = new Address(); currentCustAddress = new CustAddress(); } else { currentAddress = currentList[0]; currentAddress.Data = currentList[0].Data; currentCustAddress = customer.CustAddresses.First(c => c.Key == currentAddress.Data.Key); CacheCurrentAddress(); CacheCustAddress(); } } else { currentAddress.Data = currentList.First(c => c.Data.Key == cachedAddrKeyForRowSelection).Data; currentCustAddress = customer.CustAddresses.First(c => c.Key == currentAddress.Data.Key); CacheCurrentAddress(); CacheCustAddress(); } }
///ADDRESS DATAGRIDVIEW CONTROL private void SetUpAddressDGVControl() { addressDataGridView = new AddressDataGridView() { Dock = DockStyle.Fill }; addressDataGridView.ShowActiveColumn(); addressDataGridView.Initialize(activeAddresses); addressDataGridView.SelectionChanged += (key) => { bool proceed = NotifyIfAddressIsDirty(); if (proceed) { cachedAddrKeyForRowSelection = key; currentAddress = allAddresses.First(addr => addr.Data.Key == key); currentCustAddress = customer.CustAddresses.First(c => c.Key == key); SetFormToCurrentAddress(); CacheCurrentAddress(); CacheCustAddress(); btnSave.Enabled = false; statusLabel.Text = ""; } }; panelDGV.Controls.Add(addressDataGridView); }
public IHttpActionResult PostCustAddress(CustAddress custAddress) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CustAddresses.Add(custAddress); try { db.SaveChanges(); } catch (DbUpdateException) { if (CustAddressExists(custAddress.cust_id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = custAddress.cust_id }, custAddress)); }
public int InsertCustAddrAndAssignCustomerDefaultAddress(Customer customer, CustAddress custAddress, bool isPrimary, bool isShipTo) { custAddress.Address.Key = _addressRepository.GetSurrogateKey(); custAddress.Key = custAddress.Address.Key; custAddress.CustAddrID = custAddress.Key.ToString(); custAddress.DfltCntctKey = customer.PrimaryCntctKey; customer.CustAddresses.Add(custAddress); if (isPrimary) { customer.PrimaryAddress = custAddress.Address; customer.PrimaryAddrKey = custAddress.Address.Key; customer.DefaultBillToAddress = custAddress.Address; customer.DfltBillToAddrKey = custAddress.Address.Key; } if (isShipTo) { customer.DefaultShipToAddress = custAddress.Address; customer.DfltShipToAddrKey = custAddress.Address.Key; } _customerRepository.Update(customer); return(custAddress.Key); }
public IHttpActionResult PutCustAddress(int id, CustAddress custAddress) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != custAddress.cust_id) { return(BadRequest()); } db.Entry(custAddress).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustAddressExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void AddressControl_Done(BLAddress address) { if (address.IsDirty) { btnSave.Enabled = true; currentAddress.IsDirty = address.IsDirty; currentAddress.IsValidated = address.IsValidated; currentAddress.Data.Name = address.Data.Name; currentAddress.Data.Line1 = address.Data.Line1; currentAddress.Data.Line2 = address.Data.Line2; currentAddress.Data.City = address.Data.City; currentAddress.Data.State = address.Data.State; currentAddress.Data.Zip = address.Data.Zip; currentAddress.Data.Country = address.Data.Country; currentAddress.Data.Residential = address.Data.Residential; RemoveNullsOnEmptyAddressProperties(); var custAddr = customer.CustAddresses.FirstOrDefault(c => c.Key == currentAddress.Data.Key); var primaryCustAddr = customer.CustAddresses.FirstOrDefault(c => c.Key == customer.PrimaryAddrKey); var whseTerr = GetWarehouseAndTerritory(currentAddress.Data.State); if (custAddr == null) //new entry { custAddr = new CustAddress(); MapCustAddr(ref custAddr, primaryCustAddr); custAddr.WhseKey = whseTerr.Item1; custAddr.SalesTerritoryKey = whseTerr.Item2; custAddr.Key = address.Data.Key; custAddr.STaxSchdKey = address.SalesTaxKey; custAddr.CreateDate = DateTime.Now; custAddr.CreateUserID = userName; custAddr.UpdateDate = null; custAddr.UpdateUserID = null; custAddr.Type = CustAddrType.CSA; currentCustAddress = custAddr; } else //existing entry - doing update { MapCustAddr(ref custAddr, primaryCustAddr); custAddr.WhseKey = whseTerr.Item1; custAddr.SalesTerritoryKey = whseTerr.Item2; custAddr.STaxSchdKey = address.SalesTaxKey; custAddr.UpdateDate = DateTime.Now; custAddr.UpdateUserID = userName; custAddr.Type = CustAddrType.CSA; } SetTaxRateTextBox(); } }
public void Initialize(int _custKey, CustomerService _service) { SetUserPermissions(); currentAddress = new BLAddress(new TaxService(), new ValidationService()); currentCustAddress = new CustAddress(); service = _service; custKey = _custKey; }
public IHttpActionResult GetCustAddress(int id, string type) { CustAddress custAddress = db.CustAddresses.Find(id, type); if (custAddress == null) { return(NotFound()); } return(Ok(custAddress)); }
private void CacheCustAddress() { var currentCustAddr = customer.CustAddresses.First(c => c.Key == currentAddress.Data.Key); cachedCustAddr = new CustAddress(); cachedCustAddr.WhseKey = currentCustAddr.WhseKey; cachedCustAddr.SalesTerritoryKey = currentCustAddr.SalesTerritoryKey; cachedCustAddr.STaxSchdKey = currentCustAddr.STaxSchdKey; cachedCustAddr.UpdateDate = currentCustAddr.UpdateDate; cachedCustAddr.UpdateUserID = currentCustAddr.UpdateUserID; cachedCustAddr.Type = currentCustAddr.Type; cachedCustAddr.PmtTermsKey = currentCustAddr.PmtTermsKey; cachedCustAddr.ShipMethKey = currentCustAddr.ShipMethKey; cachedCustAddr.InvcFormKey = currentCustAddr.InvcFormKey; cachedCustAddr.PackListFormKey = currentCustAddr.PackListFormKey; cachedCustAddr.AllowInvtSubst = currentCustAddr.AllowInvtSubst; cachedCustAddr.CurrID = currentCustAddr.CurrID; cachedCustAddr.FOBKey = currentCustAddr.FOBKey; cachedCustAddr.LanguageID = currentCustAddr.LanguageID; cachedCustAddr.RequireSOAck = currentCustAddr.RequireSOAck; cachedCustAddr.ShipComplete = currentCustAddr.ShipComplete; cachedCustAddr.ShipLabelFormKey = currentCustAddr.ShipLabelFormKey; cachedCustAddr.SOAckFormKey = currentCustAddr.SOAckFormKey; cachedCustAddr.SperKey = currentCustAddr.SperKey; cachedCustAddr.BackOrdPrice = currentCustAddr.BackOrdPrice; cachedCustAddr.BOLReqd = currentCustAddr.BOLReqd; cachedCustAddr.CarrierAcctNo = currentCustAddr.CarrierAcctNo; cachedCustAddr.CarrierBillMeth = currentCustAddr.CarrierBillMeth; cachedCustAddr.CloseSOLineOnFirstShip = currentCustAddr.CloseSOLineOnFirstShip; cachedCustAddr.CloseSOOnFirstShip = currentCustAddr.CloseSOOnFirstShip; cachedCustAddr.CreateDate = currentCustAddr.CreateDate; cachedCustAddr.CreateType = currentCustAddr.CreateType; cachedCustAddr.CreateUserID = currentCustAddr.CreateUserID; cachedCustAddr.FreightMethod = currentCustAddr.FreightMethod; cachedCustAddr.InvcMsg = currentCustAddr.InvcMsg; cachedCustAddr.InvoiceReqd = currentCustAddr.InvoiceReqd; cachedCustAddr.InvcFormKey = currentCustAddr.InvcFormKey; cachedCustAddr.PackListContentsReqd = currentCustAddr.PackListContentsReqd; cachedCustAddr.PackListReqd = currentCustAddr.PackListReqd; cachedCustAddr.PriceAdj = currentCustAddr.PriceAdj; cachedCustAddr.PriceBase = currentCustAddr.PriceBase; cachedCustAddr.PrintOrderAck = currentCustAddr.PrintOrderAck; cachedCustAddr.ShipDays = currentCustAddr.ShipDays; cachedCustAddr.ShipLabelsReqd = currentCustAddr.ShipLabelsReqd; cachedCustAddr.SOAckMeth = currentCustAddr.SOAckMeth; cachedCustAddr.UsePromoPrice = currentCustAddr.UsePromoPrice; }
public IHttpActionResult DeleteCustAddress(int id, string type) { CustAddress custAddress = db.CustAddresses.Find(id, type); if (custAddress == null) { return(NotFound()); } db.CustAddresses.Remove(custAddress); db.SaveChanges(); return(Ok(custAddress)); }
private CustAddress GetHydratedCustAddress(CustClass custClass, API.Enums.CustAddrType type) { var custAdress = new CustAddress(); custAdress.AllowInvtSubst = custClass.AllowInvtSubst; custAdress.BackOrdPrice = 0; custAdress.BOLReqd = 0; custAdress.CarrierBillMeth = 6; custAdress.CloseSOLineOnFirstShip = 0; custAdress.CloseSOOnFirstShip = 0; custAdress.CreateDate = DateTime.Now; custAdress.CreateType = 0; custAdress.CreateUserID = Environment.UserName; custAdress.CurrID = custClass.CurrID; custAdress.CustAddrID = "Test - " + type.ToString(); custAdress.FOBKey = custClass.FOBKey; custAdress.FreightMethod = 2; custAdress.InvoiceReqd = 0; custAdress.LanguageID = custClass.LanguageID; custAdress.PackListContentsReqd = 0; custAdress.PackListReqd = 0; custAdress.PriceAdj = 0; custAdress.PriceBase = 0; custAdress.PrintOrderAck = 0; custAdress.PmtTermsKey = 22; custAdress.RequireSOAck = custClass.RequireSOAck; custAdress.ShipComplete = custClass.ShipComplete; custAdress.ShipDays = 3; custAdress.ShipLabelFormKey = custClass.ShipLabelFormKey; custAdress.ShipLabelsReqd = 0; custAdress.SOAckFormKey = custClass.SOAckFormKey; custAdress.SOAckMeth = 0; custAdress.SperKey = custClass.SperKey; //billtoCustAddress.WhseKey = accountSettings.WarehouseKey; custAdress.UsePromoPrice = 0; custAdress.ShipMethKey = custClass.ShipMethKey; //billtoCustAddress.WhseKey = accountSettings.WarehouseKey; custAdress.InvcFormKey = custClass.InvcFormKey; //billtoCustAddress.PackListFormKey = accountSettings.PackListFormKey; //billtoCustAddress.SalesTerritoryKey = accountSettings.TerritoryKey; custAdress.Type = type; return(custAdress); }
private void MapCustAddrSettings(ref CustAddress custAddr, AccountSettings accountSettings) { custAddr.PmtTermsKey = accountSettings.CustClass.PmtTermsKey; custAddr.ShipMethKey = accountSettings.CustClass.ShipMethKey; custAddr.InvcFormKey = accountSettings.CustClass.InvcFormKey; //not on form int key = accountSettings.CustClass.Key; custAddr.CustPriceGroupKey = key == 44 ? 7 : key == 40 ? 8 : key == 38 ? 9 : 0; custAddr.CurrID = accountSettings.CustClass.CurrID; custAddr.FOBKey = accountSettings.CustClass.FOBKey; custAddr.LanguageID = accountSettings.CustClass.LanguageID; custAddr.RequireSOAck = accountSettings.CustClass.RequireSOAck; custAddr.ShipComplete = accountSettings.CustClass.ShipComplete; custAddr.ShipLabelFormKey = accountSettings.CustClass.ShipLabelFormKey; custAddr.SOAckFormKey = accountSettings.CustClass.SOAckFormKey; custAddr.SperKey = accountSettings.CustClass.SperKey; }
private void MapCustAddr(ref CustAddress dst, CustAddress src) { dst.PmtTermsKey = src.PmtTermsKey; dst.ShipMethKey = src.ShipMethKey; dst.InvcFormKey = src.InvcFormKey; dst.PackListFormKey = src.PackListFormKey; dst.AllowInvtSubst = src.AllowInvtSubst; dst.CurrID = src.CurrID; dst.FOBKey = src.FOBKey; dst.LanguageID = src.LanguageID; dst.RequireSOAck = src.RequireSOAck; dst.ShipComplete = src.ShipComplete; dst.ShipLabelFormKey = src.ShipLabelFormKey; dst.SOAckFormKey = src.SOAckFormKey; dst.SperKey = src.SperKey; dst.BackOrdPrice = src.BackOrdPrice; dst.BOLReqd = src.BOLReqd; dst.CarrierAcctNo = src.CarrierAcctNo; dst.CarrierBillMeth = src.CarrierBillMeth; dst.CloseSOLineOnFirstShip = src.CloseSOLineOnFirstShip; dst.CloseSOOnFirstShip = src.CloseSOOnFirstShip; dst.CreateDate = src.CreateDate; dst.CreateType = src.CreateType; dst.CreateUserID = src.CreateUserID; dst.FreightMethod = src.FreightMethod; dst.InvcMsg = src.InvcMsg; dst.InvoiceReqd = src.InvoiceReqd; dst.InvcFormKey = src.InvcFormKey; dst.PackListContentsReqd = src.PackListContentsReqd; dst.PackListReqd = src.PackListReqd; dst.PriceAdj = src.PriceAdj; dst.PriceBase = src.PriceBase; dst.PrintOrderAck = src.PrintOrderAck; dst.ShipLabelsReqd = src.ShipLabelsReqd; dst.SOAckMeth = src.SOAckMeth; dst.UsePromoPrice = src.UsePromoPrice; }
//--------------NEW----------------- private void btnNew_Click(object sender, EventArgs e) { bool proceed = NotifyIfAddressIsDirty(); if (proceed) { currentAddress = new BLAddress(); currentAddress.Data = new Address(); currentCustAddress = new CustAddress(); addressControl.ClearForm(); txtTaxRate.Clear(); statusLabel.Text = string.Empty; UnsubscribeFromCheckChanged(); chkPrimaryBilling.Checked = false; chkShipping.Checked = false; chkCommon.Checked = true; rdoActive.Checked = true; rdoActive.Enabled = false; rdoDeleted.Enabled = false; SubscribeToCheckChanged(); } }
public void AddCustAddressAndAssignDefaultShipTo() { var service = new CustomerService(); var lookupService = new LookUpService(); var custClass = lookupService.GetCustClasses().First(); var custAddress = new CustAddress(); custAddress.AllowInvtSubst = custClass.AllowInvtSubst; custAddress.BackOrdPrice = 0; custAddress.BOLReqd = 0; custAddress.CarrierBillMeth = 6; custAddress.CloseSOLineOnFirstShip = 0; custAddress.CloseSOOnFirstShip = 0; custAddress.CreateDate = DateTime.Now; custAddress.CreateType = 0; custAddress.CreateUserID = Environment.UserName; custAddress.CurrID = custClass.CurrID; custAddress.CustAddrID = "Test"; custAddress.CustKey = 65932; custAddress.FOBKey = custClass.FOBKey; custAddress.FreightMethod = 2; custAddress.InvoiceReqd = 0; custAddress.LanguageID = custClass.LanguageID; custAddress.PackListContentsReqd = 0; custAddress.PackListReqd = 0; custAddress.PriceAdj = 0; custAddress.PriceBase = 0; custAddress.PrintOrderAck = 0; custAddress.RequireSOAck = custClass.RequireSOAck; custAddress.ShipComplete = custClass.ShipComplete; custAddress.ShipDays = 3; custAddress.ShipLabelFormKey = custClass.ShipLabelFormKey; custAddress.ShipLabelsReqd = 0; custAddress.SOAckFormKey = custClass.SOAckFormKey; custAddress.SOAckMeth = 0; custAddress.SperKey = custClass.SperKey; custAddress.WhseKey = 23; custAddress.UsePromoPrice = 0; custAddress.ShipMethKey = custClass.ShipMethKey; custAddress.InvcFormKey = custClass.InvcFormKey; custAddress.PackListFormKey = 84; custAddress.SalesTerritoryKey = 2; var address = new Address() { Name = "Case Parts", Line1 = "877 Monterey Pass Rd", City = "Monterey Park", State = "CA", Zip = "91754", Country = "USA", Residential = 1, TransactionOverride = 0, UpdateCounter = 1 }; custAddress.Address = address; Customer customer = service.LoadCustomerWithDependenciesByKey(29301); service.InsertCustAddrAndAssignCustomerDefaultAddress(customer, custAddress, true, true); Assert.IsTrue(true); }
public IHttpActionResult UpdateCustDetail(int user_id, Registration registration) { try { CustomerDetail customer = new CustomerDetail { cust_id = registration.cust_id, title = registration.title, first_name = registration.first_name, middle_name = registration.middle_name, last_name = registration.last_name, fathers_name = registration.fathers_name, mobile_number = registration.mobile_number, email = registration.email, aadhar = registration.aadhar, pan_card = registration.pan_card, pan_doc = registration.pan_doc, dob = registration.dob, occupation_type = registration.occupation_type, source_of_income = registration.source_of_income, gross_annual_income = registration.gross_annual_income, debit_card = registration.debit_card, net_banking = registration.net_banking, approval_status = registration.approval_status }; db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); if (registration.type_of_address == "Yes") { CustAddress addr = new CustAddress { cust_id = registration.cust_id, type_of_address = "same", line1 = registration.line1, line2 = registration.line2, landmark = registration.landmark, city = registration.city, cust_state = registration.cust_state, pin_code = registration.pin_code }; db.Entry(addr).State = EntityState.Modified; db.SaveChanges(); } else { CustAddress addr = new CustAddress { cust_id = registration.cust_id, type_of_address = "Permanent", line1 = registration.line1, line2 = registration.line2, landmark = registration.landmark, city = registration.city, cust_state = registration.cust_state, pin_code = registration.pin_code }; db.Entry(addr).State = EntityState.Modified; db.SaveChanges(); CustAddress addr2 = new CustAddress { cust_id = registration.cust_id, type_of_address = "Resident", line1 = registration.line1_residential, line2 = registration.line2_residential, landmark = registration.landmark_residential, city = registration.city_residential, cust_state = registration.cust_state_residential, pin_code = registration.pin_code_residential }; db.Entry(addr2).State = EntityState.Modified; db.SaveChanges(); } return(Ok(new { message = "Okay", customer.cust_id })); } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; } return(Ok(new { message = "Exception", exception_message = e.Message })); } }
public void UpdateCustAddress(CustAddress custAddress) { _custAddressRepository.Update(custAddress); }