public SupplierDetailEntity GetSupplierById(int supId) { try { SupplierDetailEntity suppliersource = entities.Suppliers.Where(x => x.IsDeleted != true && x.ID == supId).Select(x => new SupplierDetailEntity { ID = x.ID, SupplierName = x.Sup_Name, Sup_Bill_to_city = x.Sup_Bill_to_city, Sup_Bill_to_country = x.Sup_Bill_to_country, Sup_Bill_to_line1 = x.Sup_Bill_to_line1, Sup_Bill_to_line2 = x.Sup_Bill_to_line2, Sup_Bill_to_post_code = x.Sup_Bill_to_post_code, Sup_Bill_to_state = x.Sup_Bill_to_state, ShipAddressLine1 = x.Sup_Ship_to_line1, ShipAddressLine2 = x.Sup_Ship_to_line2, ShipCity = x.Sup_Ship_to_city, ShipCountry = x.Sup_Ship_to_country, ShipPostalCode = x.Sup_Ship_to_post_code, ShipState = x.Sup_Ship_to_state, Supp_Reg_No = x.Sup_Company_Reg_no, CreditLimitDays = x.Sup_Credit_Limit_Days.ToString(), Telephone = x.Sup_Telephone, Fax = x.Sup_Fax, Email = x.Sup_Email, ContactPerson = x.Sup_Contact_Person, GstRegistrationNo = x.Sup_GST_Reg_No, Remarks = x.Sup_Remarks, ChangeSupplierGST = x.Sup_Charge_GST, IsInActive = x.Sup_Inactive, IsRefreshed = x.IsRefreshed, RefreshedDate = x.RefreshedDate, CreditLimitAmount = x.Sup_Credit_Limit_Amount.ToString(), }).FirstOrDefault(); return(suppliersource); } catch (Exception ex) { throw ex; } }
public bool CreateSupplier(SupplierDetailEntity entity) { try { var supplier = entities.Suppliers.FirstOrDefault(x => x.ID == entity.ID); if (supplier != null) { supplier.Sup_Name = entity.SupplierName; supplier.Sup_Bill_to_city = entity.Sup_Bill_to_city; supplier.Sup_Bill_to_country = entity.Sup_Bill_to_country; supplier.Sup_Bill_to_line1 = entity.Sup_Bill_to_line1; supplier.Sup_Bill_to_line2 = entity.Sup_Bill_to_line2; supplier.Sup_Bill_to_post_code = entity.Sup_Bill_to_post_code; supplier.Sup_Bill_to_state = entity.Sup_Bill_to_state; supplier.Sup_Company_Reg_no = entity.Supp_Reg_No; supplier.Sup_Contact_Person = entity.ContactPerson; supplier.Sup_Credit_Limit_Amount = Convert.ToDecimal(entity.CreditLimitAmount); supplier.Sup_Credit_Limit_Days = entity.CreditLimitDays == string.Empty ? null as Int32? : Convert.ToInt32(entity.CreditLimitDays); supplier.Sup_Email = entity.Email; supplier.Sup_Fax = entity.Fax; supplier.Sup_GST_Reg_No = entity.GstRegistrationNo; supplier.Sup_Remarks = entity.Remarks; supplier.Sup_Ship_to_city = entity.ShipCity; supplier.Sup_Ship_to_country = entity.ShipCountry; supplier.Sup_Ship_to_line1 = entity.ShipAddressLine1; supplier.Sup_Ship_to_line2 = entity.ShipAddressLine2; supplier.Sup_Ship_to_post_code = entity.ShipPostalCode; supplier.Sup_Ship_to_state = entity.ShipState; supplier.Sup_Telephone = entity.Telephone; supplier.Sup_Charge_GST = entity.ChangeSupplierGST; supplier.Sup_Inactive = entity.IsInActive; supplier.TaxId = entity.TaxId; entities.SaveChanges(); return(true); } else { Supplier supplierdetail = new Supplier() { Sup_Name = entity.SupplierName, Sup_Bill_to_city = entity.Sup_Bill_to_city, Sup_Bill_to_country = entity.Sup_Bill_to_country, Sup_Bill_to_line1 = entity.Sup_Bill_to_line1, Sup_Bill_to_line2 = entity.Sup_Bill_to_line2, Sup_Bill_to_post_code = entity.Sup_Bill_to_post_code, Sup_Bill_to_state = entity.Sup_Bill_to_state, Sup_Company_Reg_no = entity.Supp_Reg_No, Sup_Contact_Person = entity.ContactPerson, Sup_Credit_Limit_Amount = Convert.ToDecimal(entity.CreditLimitAmount), Sup_Credit_Limit_Days = entity.CreditLimitDays == string.Empty ? null as Int32? : Convert.ToInt32(entity.CreditLimitDays), Sup_Email = entity.Email, Sup_Fax = entity.Fax, Sup_GST_Reg_No = entity.GstRegistrationNo, Sup_Remarks = entity.Remarks, Sup_Ship_to_city = entity.ShipCity, Sup_Ship_to_country = entity.ShipCountry, Sup_Ship_to_line1 = entity.ShipAddressLine1, Sup_Ship_to_line2 = entity.ShipAddressLine2, Sup_Ship_to_post_code = entity.ShipPostalCode, Sup_Ship_to_state = entity.ShipState, Sup_Telephone = entity.Telephone, Sup_Charge_GST = entity.ChangeSupplierGST, Sup_Inactive = entity.IsInActive, TaxId = entity.SelectedTaxId }; entities.Suppliers.Add(supplierdetail); entities.SaveChanges(); return(true); } } catch { return(false); } //if (entities.SupplierDetails.AsNoTracking().FirstOrDefault(x => x.ID == entity.ID) == null) //{ // entities.SupplierDetails.Add(entity); //} //else //{ // entities.Entry(entity).State = EntityState.Modified; //} }
//public List<CatagoryType> GetCustomerType() //{ // ICustomersDAL customerDAL = new CustomersDAL(); // List<CatagoryType> result = customerDAL.GetCustomerType(); // return result; //} //public List<CatagoryType> GetCategoryType(string filter) //{ // ICustomersDAL customerDAL = new CustomersDAL(); // List<CatagoryType> result = customerDAL.GetCategoryType(filter); // return result; //} //public IEnumerable<ShippingAddress> GetShippingAddress(int customerId) //{ // ICustomersDAL customerDAL = new CustomersDAL(); // return customerDAL.GetShippingAddress(customerId); //} public bool CreateSupplier(SupplierDetailEntity entity) { ISupplierDAL supplierDAL = new SupplierDAL(); return(supplierDAL.CreateSupplier(entity)); }
//public IEnumerable<CatagoryType> GetCustomerType() //{ // ICustomersBL _customerBL = new CustomersBL(); // var ctype = _customerBL.GetCustomerType(); // return ctype; //} //public IEnumerable<CatagoryType> GetCatagoryType(string cat_type) //{ // ICustomersBL _customerBL = new CustomersBL(); // var ctype = _customerBL.GetCategoryType(cat_type); // return ctype; //} //public IEnumerable<ShippingAddress> GetShippingAddress(int customerId) //{ // ICustomersBL _customerBL = new CustomersBL(); // return _customerBL.GetShippingAddress(customerId); //} public bool CreateSupplier(SupplierDetailEntity entity) { ISupplierBL _supplierBL = new SupplierBL(); return(_supplierBL.CreateSupplier(entity)); }
void OnSaveSupplier(object param) { Mouse.OverrideCursor = Cursors.Wait; SupplierDetailEntity supplier = new SupplierDetailEntity(); supplier.ID = this.SelectedSearchSupplier; supplier.SupplierName = this.SupplierName; supplier.Email = this.Email; supplier.Fax = this.Fax; supplier.Telephone = this.Telephone; supplier.Supp_Reg_No = this.Supp_Reg_No; supplier.Sup_Bill_to_city = this.Sup_Bill_to_city; supplier.Sup_Bill_to_country = this.Sup_Bill_to_country; supplier.Sup_Bill_to_line1 = this.Sup_Bill_to_line1; supplier.Sup_Bill_to_line2 = this.Sup_Bill_to_line2; supplier.Sup_Bill_to_post_code = this.Sup_Bill_to_post_code; supplier.Sup_Bill_to_state = this.Sup_Bill_to_state; supplier.ShipAddressLine1 = this.ShipAddressLine1; supplier.ShipAddressLine2 = this.ShipAddressLine2; supplier.ShipCity = this.ShipCity; supplier.ShipCountry = this.ShipCountry; supplier.ShipState = this.ShipState; supplier.ShipPostalCode = this.ShipPostalCode; supplier.ContactPerson = this.ContactPerson; supplier.GstRegistrationNo = this.GstRegistrationNo; supplier.Remarks = this.Remarks; supplier.IsInActive = this.IsInActive; supplier.ChangeSupplierGST = this.ChangeSupplierGST; supplier.Balance = this.Balance; supplier.ID = this.ID; supplier.CreditLimitAmount = this.CreditLimitAmount; supplier.CreditLimitDays = this.CreditLimitDays; supplier.TaxId = this.SelectedTaxId; MessageBoxResult result = MessageBox.Show("Do you want to save changes?", "Save Content", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: ISupplierRepository supplierRepository = new SupplierRepository(); var savesupplier = supplierRepository.CreateSupplier(supplier); if (savesupplier) { if (this.ID == 0) { //this.SearchSupplier = supplierRepository.GetAllSupplier().ToList(); //var SupplierIdSelected = this.SearchSupplier[this.SearchSupplier.Count - 1].ID; //this.SelectedSearchSupplier = SupplierIdSelected; RefreshData(); } else { this.TotalSupplier = supplierRepository.GetAllSupplier().Count(); this.InActiveSupplier = supplierRepository.GetSupplierCount("Y"); this.ActiveSupplier = TotalSupplier - InActiveSupplier; } } else { MessageBox.Show("There was some problem while updating the values, Kindly try again later."); } break; case MessageBoxResult.No: break; } //if (supplier.ChangeSupplierGST == true) //{ // this.ChangeSupplierGSTTrue = supplier.ChangeSupplierGST; // this.ChangeSupplierGSTFalse = false; //} //else //{ // this.ChangeSupplierGSTTrue = false; // this.ChangeSupplierGSTFalse = true; //} Mouse.OverrideCursor = null; }