/// <summary> /// This method is used to save category contents with associated category /// </summary> /// <param name="content"></param> public void SaveCategoryContent(ContentModel content) { using (SDNSettingEntities objCategoryEntities = new SDNSettingEntities()) { var obj = objCategoryEntities.CategoriesContents.Where(x => x.Cat_Id == content.CategoryID && x.IsDeleted != true && x.Set_Default == true && content.IsSelected == true).FirstOrDefault(); if (obj != null) { obj.Set_Default = false; objCategoryEntities.SaveChanges(); } try { CategoriesContent catContent = new CategoriesContent(); catContent.Cat_Contents = content.ContentName.Trim(); catContent.Content_Limit = content.Limit; catContent.Cat_Id = content.CategoryID; catContent.IsDeleted = false; catContent.Set_Default = content.IsSelected; catContent.CreatedDate = DateTime.Now; objCategoryEntities.CategoriesContents.Add(catContent); objCategoryEntities.SaveChanges(); } catch (Exception ex) { throw ex; } } }
/// <summary> /// This method is used to update category contents with associated category /// </summary> /// <param name="content"></param> public void UpdateCategoryContent(ContentModel content) { using (SDNSettingEntities objCategoryEntities = new SDNSettingEntities()) { try { var obj = objCategoryEntities.CategoriesContents.Where(x => x.Cat_Id == content.CategoryID && x.IsDeleted != true && x.Set_Default == true && content.IsSelected == true).FirstOrDefault(); if (obj != null) { obj.Set_Default = false; objCategoryEntities.SaveChanges(); } CategoriesContent catContent = objCategoryEntities.CategoriesContents.SingleOrDefault(i => i.ID == content.ContentID); if (catContent != null) { catContent.Cat_Contents = content.ContentName; catContent.Content_Limit = content.Limit; catContent.Set_Default = content.IsSelected; catContent.ModifiedDate = DateTime.Now; objCategoryEntities.SaveChanges(); } //var categoryContent = objCategoryEntities.CategoriesContents.Where(e => e.Cat_Id == content.CategoryID && e.ID!=content.ContentID).ToList(); //if (categoryContent != null) //{ // foreach (var c in categoryContent) // { // if (content.IsSelected == true) // { // if (c.Set_Default == true) // { // c.Set_Default = false; // } // } // else // { // if(c.Set_Default==true) // { // c.Set_Default = true; // } // } // objCategoryEntities.SaveChanges(); // } //} } catch (Exception ex) { throw ex; } } }
/// <summary> /// This method is used to save new tax /// </summary> /// <param name="taxModel"></param> public void SaveTax(TaxModel taxModel) { try { using (SDNSettingEntities objEntities = new SDNSettingEntities()) { TaxCodesAndRate tax = new TaxCodesAndRate(); tax.Tax_Name = taxModel.TaxName; tax.Tax_Description = taxModel.TaxDescription.Trim(); tax.Tax_Code = taxModel.TaxCode.Trim(); tax.Tax_Rate = taxModel.TaxRate; if (taxModel.IsInActive == null) { tax.Tax_Inactive = "N"; } else { tax.Tax_Inactive = taxModel.IsInActive; } tax.Tax_Default = false; tax.CreatedDate = DateTime.Now; tax.IsDeleted = false; objEntities.TaxCodesAndRates.Add(tax); objEntities.SaveChanges(); var taxes = objEntities.TaxCodesAndRates.ToList(); if (taxes != null) { foreach (var taxItem in taxes) { taxItem.Tax_Name = taxModel.TaxName; objEntities.SaveChanges(); } } } } catch (Exception ex) { throw ex; } }
public bool SaveUsers(List <UsersSecurityEntity> Users) { try { foreach (var item in Users) { if (item.Password != null && item.Password != "") { item.EncryptedPassword = Encrypt(item.Password); } var checkuser = entites.Users.Where(x => x.UserId == item.ID).FirstOrDefault(); if (checkuser != null) { checkuser.User_Name = item.UserName; checkuser.User_Password = item.EncryptedPassword; checkuser.Active = item.Isinactive; checkuser.CreatedDate = DateTime.Now; checkuser.User_Email = "*****@*****.**"; entites.SaveChanges(); } else { User user = new User() { User_Name = item.UserName, User_Password = item.EncryptedPassword, Active = item.Isinactive, CreatedDate = DateTime.Now, User_Email = "*****@*****.**" }; entites.Users.Add(user); entites.SaveChanges(); } } return(true); } catch (Exception ex) { return(false); //throw ex; } }
/// <summary> /// This method is used to delete the tax /// </summary> /// <param name="id"></param> public void DeleteTax(int id) { try { using (SDNSettingEntities objEntities = new SDNSettingEntities()) { TaxCodesAndRate tax = objEntities.TaxCodesAndRates.SingleOrDefault(t => t.ID == id); tax.IsDeleted = true; tax.ModifiedDate = DateTime.Now; objEntities.SaveChanges(); } } catch (Exception ex) { throw ex; } }
/// <summary> /// This method is used to save Purchase and sales Category Content /// </summary> /// <param name="content"></param> public void SavePSCategoryContent(ContentModel content) { using (SDNSettingEntities objCategoryEntities = new SDNSettingEntities()) { try { var tandc = objCategoryEntities.TermsAndConditions.Where(e => e.Cat_Code == content.CategoryCode).SingleOrDefault(); if (tandc != null) { tandc.Cat_Content = content.ContentName; objCategoryEntities.SaveChanges(); } } catch (Exception ex) { throw ex; } } }
/// <summary> /// This method is used to delete Category Content /// </summary> /// <param name="catId"></param> public void DeleteCategoryContent(int contentID) { using (SDNSettingEntities objCategoryEntities = new SDNSettingEntities()) { try { CategoriesContent catContent = objCategoryEntities.CategoriesContents.SingleOrDefault(i => i.ID == contentID); if (catContent != null) { catContent.IsDeleted = true; objCategoryEntities.SaveChanges(); } } catch (Exception ex) { throw ex; } } }
/// <summary> /// This method is used to save Tax Name /// </summary> /// <param name="taxName"></param> public void SaveTaxName(string taxName) { using (SDNSettingEntities objCategoryEntities = new SDNSettingEntities()) { try { var taxes = objCategoryEntities.TaxCodesAndRates.ToList(); if (taxes.Count > 0) { foreach (var tax in taxes) { tax.Tax_Name = taxName; objCategoryEntities.SaveChanges(); } } } catch (Exception ex) { throw ex; } } }
public bool AddEditOptions(OptionsEntity optionEntity) { var options = entites.Options.FirstOrDefault(); try { if (options != null) { Option opt = entites.Options.FirstOrDefault(); opt.Allow_Edit_Discount = optionEntity.AllowEditDiscount == null ? false : optionEntity.AllowEditDiscount; opt.Allow_Edit_PS_Name_Desc = optionEntity.AllowEditPSNameDesc == null ? false : optionEntity.AllowEditPSNameDesc; opt.Allow_Edit_PS_Price = optionEntity.AllowEditPSPrice == null ? false : optionEntity.AllowEditPSPrice; opt.Allow_to_Create_Sales_Inv = optionEntity.AllowToCreateSaleInv == null ? false : optionEntity.AllowToCreateSaleInv; opt.Cus_Detail_Allow_Chg_Limit = optionEntity.CusDetailAllowChgLimit == null ? false : optionEntity.CusDetailAllowChgLimit; opt.Hide_Discount_Column = optionEntity.HideDiscColumn == null ? false : optionEntity.HideDiscColumn; opt.Print_Del_Sales_Inv = optionEntity.PrintDelSalesInv == null ? false : optionEntity.PrintDelSalesInv; opt.Print_PS_Name = optionEntity.PrintPSName == null ? false : optionEntity.PrintPSName; opt.Print_PS_Name_Desc = optionEntity.PrintPSNameDesc == null ? false : optionEntity.PrintPSNameDesc; opt.PS_Detail_Allow_Chg_Act = optionEntity.PSDetailAllowChgAct == null ? false : optionEntity.PSDetailAllowChgAct; opt.PS_Qty_Jump_Next_Line = optionEntity.PSQtyJumNextLine == null ? false : optionEntity.PSQtyJumNextLine; opt.Show_Account_Balance = optionEntity.ShowAccountBal == null ? false : optionEntity.ShowAccountBal; opt.Show_PS_Name = optionEntity.ShowPSName == null ? false : optionEntity.ShowPSName; opt.Show_Amount_Inc_GST = optionEntity.ShowAmountIncGST == null ? false : optionEntity.ShowAmountIncGST; opt.Show_PS_Name_Desc = optionEntity.ShowPSNameDesc == null ? false : optionEntity.ShowPSNameDesc; opt.Starting_Sales_Inv_No = optionEntity.StartingSalesInvNo; opt.Number_Format = optionEntity.CurrencyName; opt.Date_Format = optionEntity.DateFormat; opt.Name_to_Print_Sales_Invoice = optionEntity.NametoPrintSalesInv; opt.Decimal_Places = Convert.ToByte(optionEntity.DecimalPlaces); opt.Def_Cash_Bank_Acc = optionEntity.AccountID; opt.Currency_Code = optionEntity.CurrencyCode; opt.ModifiedBy = 0; opt.ModifiedDate = DateTime.Now; entites.SaveChanges(); return(true); } else { Option optionDetails = new Option() { Allow_Edit_Discount = optionEntity.AllowEditDiscount == null ? false : optionEntity.AllowEditDiscount, Allow_Edit_PS_Name_Desc = optionEntity.AllowEditPSNameDesc == null ? false : optionEntity.AllowEditPSNameDesc, Allow_Edit_PS_Price = optionEntity.AllowEditPSPrice == null ? false : optionEntity.AllowEditPSPrice, Allow_to_Create_Sales_Inv = optionEntity.AllowToCreateSaleInv == null ? false : optionEntity.AllowToCreateSaleInv, Cus_Detail_Allow_Chg_Limit = optionEntity.CusDetailAllowChgLimit == null ? false : optionEntity.CusDetailAllowChgLimit, Hide_Discount_Column = optionEntity.HideDiscColumn == null ? false : optionEntity.HideDiscColumn, Print_Del_Sales_Inv = optionEntity.PrintDelSalesInv == null ? false : optionEntity.PrintDelSalesInv, Print_PS_Name = optionEntity.PrintPSName == null ? false : optionEntity.PrintPSName, Print_PS_Name_Desc = optionEntity.PrintPSNameDesc == null ? false : optionEntity.PrintPSNameDesc, PS_Detail_Allow_Chg_Act = optionEntity.PSDetailAllowChgAct == null ? false : optionEntity.PSDetailAllowChgAct, PS_Qty_Jump_Next_Line = optionEntity.PSQtyJumNextLine == null ? false : optionEntity.PSQtyJumNextLine, Show_Account_Balance = optionEntity.ShowAccountBal == null ? false : optionEntity.ShowAccountBal, Show_PS_Name = optionEntity.ShowPSName == null ? false : optionEntity.ShowPSName, Show_Amount_Inc_GST = optionEntity.ShowAmountIncGST == null ? false : optionEntity.ShowAmountIncGST, Show_PS_Name_Desc = optionEntity.ShowPSNameDesc == null ? false : optionEntity.ShowPSNameDesc, Starting_Sales_Inv_No = optionEntity.StartingSalesInvNo, Number_Format = optionEntity.CurrencyName, Date_Format = optionEntity.DateFormat, Name_to_Print_Sales_Invoice = optionEntity.NametoPrintSalesInv, Decimal_Places = Convert.ToByte(optionEntity.DecimalPlaces), Def_Cash_Bank_Acc = optionEntity.AccountID, Currency_Code = optionEntity.CurrencyCode, CreatedBy = 0, CreatedDate = DateTime.Now }; entites.Options.Add(optionDetails); entites.SaveChanges(); return(true); } } catch (Exception ex) { return(false); throw ex; } }
public bool AddCompanyDAL(CompanyDetailsEntities companyDetail) { using (var ts = entites.Database.BeginTransaction()) { try { CompanyDetail result = entites.CompanyDetails.FirstOrDefault();// query.ToList(); if (result != null) { result.Comp_Email = companyDetail.Comp_Email; result.Comp_Fax = companyDetail.Comp_Fax; result.Comp_GST_Dereg_Date = companyDetail.Comp_GST_Dereg_Date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_GST_Dereg_Date); result.Comp_GST_Reg_Date = companyDetail.Comp_GST_Reg_Date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_GST_Reg_Date); result.Comp_GST_Reg_No = companyDetail.Comp_GST_Reg_No; result.Comp_Logo = companyDetail.Comp_logo; result.Comp_Name = companyDetail.CompanyName; result.Comp_Reg_No = companyDetail.Comp_Reg_No; result.Comp_Tel = companyDetail.Comp_Tel; result.Comp_year_end_date = companyDetail.Comp_year_end_date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_year_end_date); result.Comp_year_start_date = companyDetail.Comp_year_start_date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_year_start_date); result.CreatedBy = 0; result.CreatedDate = DateTime.Now; result.Software_Ser_No = companyDetail.Software_Ser_No; result.Comp_Bill_to_city = companyDetail.Company_BillTo_City; result.Comp_Bill_to_country = companyDetail.Company_BillTo_Country; result.Comp_Bill_to_line1 = companyDetail.Company_BillTo_Line1; result.Comp_Bill_to_line2 = companyDetail.Company_BillTo_Line2; result.Comp_Bill_to_post_code = companyDetail.Company_BillTo_PostalCode; result.Comp_Bill_to_state = companyDetail.Company_BillTo_State; result.Comp_Ship_to_city = companyDetail.ShipTo_City; result.Comp_Ship_to_country = companyDetail.ShipTo_Country; result.Comp_Ship_to_line1 = companyDetail.ShipTo_Line1; result.Comp_Ship_to_line2 = companyDetail.ShipTo_Line2; result.Comp_Ship_to_post_code = companyDetail.ShipTo_PostalCode; result.Comp_Ship_to_state = companyDetail.ShipTo_State; entites.SaveChanges(); //if (companyDetail.ShippingID != 0) //{ // ShippingAddress editshipadd = entites.ShippingAddresses.Where(x => x.ID == companyDetail.ShippingID).FirstOrDefault(); // if (editshipadd!=null) // { // editshipadd.Ship_to_city = companyDetail.ShipTo_City; // editshipadd.Ship_to_country = companyDetail.ShipTo_Country; // editshipadd.Ship_to_line1 = companyDetail.ShipTo_Line1; // editshipadd.Ship_to_line2 = companyDetail.ShipTo_Line2; // editshipadd.Ship_to_post_code = companyDetail.ShipTo_PostalCode; // editshipadd.Ship_to_state = companyDetail.ShipTo_State; // entites.SaveChanges(); // } //} //else //{ // if (companyDetail.ShipTo_City != null|| companyDetail.ShipTo_Country!=null|| companyDetail.ShipTo_Line1 !=null|| companyDetail.ShipTo_Line2!=null) // { // ShippingAddress shipaddress = new ShippingAddress() // { // Ship_to_city = companyDetail.ShipTo_City, // EntityId = companyDetail.ID, // EntityType = "Company", // Ship_to_country = companyDetail.ShipTo_Country, // Ship_to_line1 = companyDetail.ShipTo_Line1, // Ship_to_line2 = companyDetail.ShipTo_Line2, // Ship_to_post_code = companyDetail.ShipTo_PostalCode, // Ship_to_state = companyDetail.ShipTo_State // }; // entites.ShippingAddresses.Add(shipaddress); // entites.SaveChanges(); // } //} ts.Commit(); return(true); } else { CompanyDetail CompDetail = new CompanyDetail() { Comp_Email = companyDetail.Comp_Email, Comp_Fax = companyDetail.Comp_Fax, Comp_GST_Dereg_Date = companyDetail.Comp_GST_Dereg_Date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_GST_Dereg_Date), Comp_GST_Reg_Date = companyDetail.Comp_GST_Reg_Date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_GST_Reg_Date), Comp_GST_Reg_No = companyDetail.Comp_GST_Reg_No, Comp_Logo = companyDetail.Comp_logo, Comp_Name = companyDetail.CompanyName, Comp_Reg_No = companyDetail.Comp_Reg_No, Comp_Tel = companyDetail.Comp_Tel, Comp_year_end_date = companyDetail.Comp_year_end_date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_year_end_date), Comp_year_start_date = companyDetail.Comp_year_start_date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_year_start_date), CreatedBy = 0, CreatedDate = DateTime.Now, Software_Ser_No = companyDetail.Software_Ser_No, Comp_Bill_to_city = companyDetail.Company_BillTo_City, Comp_Bill_to_country = companyDetail.Company_BillTo_Country, Comp_Bill_to_line1 = companyDetail.Company_BillTo_Line1, Comp_Bill_to_line2 = companyDetail.Company_BillTo_Line2, Comp_Bill_to_post_code = companyDetail.Company_BillTo_PostalCode, Comp_Bill_to_state = companyDetail.Company_BillTo_State, Comp_Ship_to_city = companyDetail.ShipTo_City, Comp_Ship_to_country = companyDetail.ShipTo_Country, Comp_Ship_to_line1 = companyDetail.ShipTo_Line1, Comp_Ship_to_line2 = companyDetail.ShipTo_Line2, Comp_Ship_to_post_code = companyDetail.ShipTo_PostalCode, Comp_Ship_to_state = companyDetail.ShipTo_State }; entites.CompanyDetails.Add(CompDetail); entites.SaveChanges(); //autoID = CompDetail.ID; //ShippingAddress shipaddress = new ShippingAddress() //{ // Ship_to_city = companyDetail.ShipTo_City, // EntityId = autoID, // EntityType = "Company", // Ship_to_country = companyDetail.ShipTo_Country, // Ship_to_line1 = companyDetail.ShipTo_Line1, // Ship_to_line2 = companyDetail.ShipTo_Line2, // Ship_to_post_code = companyDetail.ShipTo_PostalCode, // Ship_to_state = companyDetail.ShipTo_State //}; //entites.ShippingAddresses.Add(shipaddress); //entites.SaveChanges(); ts.Commit(); return(true); } } catch (Exception ex) { ts.Rollback(); return(false); throw ex; } } }
/// <summary> /// This method is used to update the tax /// </summary> /// <param name="taxModel"></param> public void UpdateTax(TaxModel taxModel) { try { using (SDNSettingEntities objEntities = new SDNSettingEntities()) { TaxCodesAndRate tax = objEntities.TaxCodesAndRates.SingleOrDefault(t => t.ID == taxModel.TaxID); tax.Tax_Name = taxModel.TaxName; tax.Tax_Description = taxModel.TaxDescription; tax.Tax_Code = taxModel.TaxCode; tax.Tax_Rate = Convert.ToDecimal(taxModel.TaxRate); if (taxModel.IsInActive == null) { tax.Tax_Inactive = "N"; } else { tax.Tax_Inactive = taxModel.IsInActive; } tax.Tax_Default = taxModel.IsDefault; tax.ModifiedDate = DateTime.Now; objEntities.SaveChanges(); var lstTax = objEntities.TaxCodesAndRates.Where(e => e.ID != taxModel.TaxID).ToList(); if (tax != null) { foreach (var c in lstTax) { if (taxModel.IsDefault == true) { if (c.Tax_Default == true) { c.Tax_Default = false; } } else { if (c.Tax_Default == true) { c.Tax_Default = true; } } objEntities.SaveChanges(); } } var taxes = objEntities.TaxCodesAndRates.ToList(); if (taxes != null) { foreach (var taxItem in taxes) { taxItem.Tax_Name = taxModel.TaxName; objEntities.SaveChanges(); } } } } catch (Exception ex) { throw ex; } }