public ActionResult HSNCode(HSNCode obj, FormCollection fc) { try { //if (bl_hsn.Check_Tax(obj.gstTax, obj.gstTaxID)) //{ if (bl_hsn.SAVE(obj)) { if (obj.hsnCodeID == 0) { ModelState.Clear(); TempData["Msg"] = "HSN Code Saved Successfully !"; return(RedirectToAction("HSNCode", "HSNCode")); } else { ModelState.Clear(); TempData["Msg"] = "HSN Code Updated Successfully !"; return(RedirectToAction("HSNCode", "HSNCode")); } } else { ModelState.Clear(); TempData["Msg"] = "HSN Code Not Saved !"; return(RedirectToAction("HSNCode", "HSNCode")); } //} //else //{ // ViewData["flag"] = "Error"; // TempData["Msg"] = "HSN Code Already Exists !"; // return RedirectToAction("GSTPercentage", "GSTPercentage"); //} } catch (Exception ex) { return(RedirectToAction("HSNCode", "HSNCode")); } }
public bool AddNewItem(PharmaBusinessObjects.Master.ItemMaster newItem) { try { using (PharmaDBEntities context = new PharmaDBEntities()) { using (var transaction = context.Database.BeginTransaction()) { try { int _result = 0; int totalItemsFromSameCompany = context.ItemMaster.Where(p => p.CompanyID == newItem.CompanyID).Count(); totalItemsFromSameCompany++; //Add HSN if does not exist if (!context.HSNCode.Where(x => x.HSNCode1 == newItem.HSNCode).Any()) { Entity.HSNCode HSNCodeDBEntry = new HSNCode() { HSNCode1 = newItem.HSNCode, HSNDescription = newItem.HSNCode + "- Default Description", CreatedBy = this.LoggedInUser.Username, CreatedOn = System.DateTime.Now }; context.HSNCode.Add(HSNCodeDBEntry); } string companyCode = context.CompanyMaster.Where(p => p.CompanyId == newItem.CompanyID).FirstOrDefault().CompanyCode; Entity.ItemMaster newItemMasterDB = new Entity.ItemMaster(); newItemMasterDB.ItemCode = string.Concat(companyCode, totalItemsFromSameCompany.ToString().PadLeft((9 - companyCode.Length), '0')); newItemMasterDB.ItemName = newItem.ItemName; newItemMasterDB.CompanyID = newItem.CompanyID; newItemMasterDB.ConversionRate = newItem.ConversionRate; newItemMasterDB.ShortName = newItem.ShortName; newItemMasterDB.Packing = newItem.Packing; newItemMasterDB.PurchaseRate = newItem.PurchaseRate; newItemMasterDB.MRP = newItem.MRP; newItemMasterDB.SaleRate = newItem.SaleRate; newItemMasterDB.SpecialRate = newItem.SpecialRate; newItemMasterDB.WholeSaleRate = newItem.WholeSaleRate; newItemMasterDB.SaleExcise = newItem.SaleExcise; newItemMasterDB.SurchargeOnSale = newItem.SurchargeOnSale; newItemMasterDB.TaxOnSale = newItem.TaxOnSale; newItemMasterDB.Scheme1 = newItem.Scheme1; newItemMasterDB.Scheme2 = newItem.Scheme2; newItemMasterDB.PurchaseExcise = newItem.PurchaseExcise; newItemMasterDB.UPC = newItem.UPC; newItemMasterDB.IsHalfScheme = newItem.IsHalfScheme; newItemMasterDB.IsQTRScheme = newItem.IsQTRScheme; newItemMasterDB.SpecialDiscount = newItem.SpecialDiscount; newItemMasterDB.SpecialDiscountOnQty = newItem.SpecialDiscountOnQty; newItemMasterDB.IsFixedDiscount = newItem.IsFixedDiscount; newItemMasterDB.FixedDiscountRate = newItem.FixedDiscountRate; newItemMasterDB.SurchargeOnPurchase = newItem.SurchargeOnPurchase; newItemMasterDB.TaxOnPurchase = newItem.TaxOnPurchase; newItemMasterDB.DiscountRecieved = newItem.DiscountRecieved; newItemMasterDB.SpecialDiscountRecieved = newItem.SpecialDiscountRecieved; newItemMasterDB.QtyPerCase = newItem.QtyPerCase; newItemMasterDB.Location = newItem.Location; newItemMasterDB.SaleTypeId = newItem.SaleTypeId; newItemMasterDB.PurchaseTypeId = newItem.PurchaseTypeId; newItemMasterDB.HSNCode = newItem.HSNCode; newItemMasterDB.Status = newItem.Status; newItemMasterDB.CreatedBy = this.LoggedInUser.Username; newItemMasterDB.CreatedOn = System.DateTime.Now; context.ItemMaster.Add(newItemMasterDB); _result = context.SaveChanges(); transaction.Commit(); if (_result > 0) { return(true); } else { return(false); } } catch (DbEntityValidationException ex) { transaction.Rollback(); throw ex; } catch (Exception ex) { transaction.Rollback(); throw ex; } } } } catch (Exception ex) { throw ex; } }
public bool UpdateItem(PharmaBusinessObjects.Master.ItemMaster existingItem) { using (PharmaDBEntities context = new PharmaDBEntities()) { using (var transaction = context.Database.BeginTransaction()) { try { int _result = 0; Entity.ItemMaster existingItemDB = context.ItemMaster.Where(p => p.ItemCode == existingItem.ItemCode && p.Status).FirstOrDefault(); //Add HSN if does not exist if (!context.HSNCode.Where(x => x.HSNCode1 == existingItem.HSNCode).Any()) { Entity.HSNCode HSNCodeDBEntry = new HSNCode() { HSNCode1 = existingItem.HSNCode, HSNDescription = existingItem.HSNCode + "- Default Description", CreatedBy = this.LoggedInUser.Username, CreatedOn = System.DateTime.Now }; context.HSNCode.Add(HSNCodeDBEntry); } if (existingItemDB != null) { existingItemDB.ItemName = existingItem.ItemName; existingItemDB.CompanyID = existingItem.CompanyID; existingItemDB.ConversionRate = existingItem.ConversionRate; existingItemDB.ShortName = existingItem.ShortName; existingItemDB.Packing = existingItem.Packing; existingItemDB.PurchaseRate = existingItem.PurchaseRate; existingItemDB.MRP = existingItem.MRP; existingItemDB.SaleRate = existingItem.SaleRate; existingItemDB.SpecialRate = existingItem.SpecialRate; existingItemDB.WholeSaleRate = existingItem.WholeSaleRate; existingItemDB.SaleExcise = existingItem.SaleExcise; existingItemDB.SurchargeOnSale = existingItem.SurchargeOnSale; existingItemDB.TaxOnSale = existingItem.TaxOnSale; existingItemDB.Scheme1 = existingItem.Scheme1; existingItemDB.Scheme2 = existingItem.Scheme2; existingItemDB.PurchaseExcise = existingItem.PurchaseExcise; existingItemDB.UPC = existingItem.UPC; existingItemDB.IsHalfScheme = existingItem.IsHalfScheme; existingItemDB.IsQTRScheme = existingItem.IsQTRScheme; existingItemDB.SpecialDiscount = existingItem.SpecialDiscount; existingItemDB.SpecialDiscountOnQty = existingItem.SpecialDiscountOnQty; existingItemDB.IsFixedDiscount = existingItem.IsFixedDiscount; existingItemDB.FixedDiscountRate = existingItem.FixedDiscountRate; existingItemDB.SurchargeOnPurchase = existingItem.SurchargeOnPurchase; existingItemDB.TaxOnPurchase = existingItem.TaxOnPurchase; existingItemDB.DiscountRecieved = existingItem.DiscountRecieved; existingItemDB.SpecialDiscountRecieved = existingItem.SpecialDiscountRecieved; existingItemDB.QtyPerCase = existingItem.QtyPerCase; existingItemDB.Location = existingItem.Location; existingItemDB.SaleTypeId = existingItem.SaleTypeId; existingItemDB.PurchaseTypeId = existingItem.PurchaseTypeId; existingItemDB.HSNCode = existingItem.HSNCode; existingItemDB.Status = existingItem.Status; existingItemDB.ModifiedBy = this.LoggedInUser.Username; existingItemDB.ModifiedOn = System.DateTime.Now; } _result = context.SaveChanges(); transaction.Commit(); _result = 1; if (_result > 0) { return(true); } else { return(false); } } catch (Exception) { transaction.Rollback(); return(false); } } } }
internal void textChanged(object changedString) { switch (changedString as string) { case "HSNCode": { if (!string.IsNullOrEmpty(HSNCode) && SelectedRecord == null) { HSNList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("HSNCode").ToLower().Contains(HSNCode.ToLower())); HSNList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "GoodsDesc": { if (!string.IsNullOrEmpty(GoodsDesc) && SelectedRecord == null) { HSNList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("goods_Description").ToLower().Contains(GoodsDesc.ToLower())); HSNList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "CGST": { if (!string.IsNullOrEmpty(CGST) && SelectedRecord == null) { HSNList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("CGST").ToLower().Contains(CGST.ToLower())); HSNList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "SGST": { if (!string.IsNullOrEmpty(SGST) && SelectedRecord == null) { HSNList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("SGST").ToLower().Contains(SGST.ToLower())); HSNList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "IGST": { if (!string.IsNullOrEmpty(IGST) && SelectedRecord == null) { HSNList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("IGST").ToLower().Contains(IGST.ToLower())); HSNList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "CompCess": { if (!string.IsNullOrEmpty(CompCess) && SelectedRecord == null) { HSNList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("CompensationCess").ToLower().Contains(CompCess.ToLower())); HSNList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; case "IsValidHSN": { if (!string.IsNullOrEmpty(IsValidHSN) && SelectedRecord == null) { HSNList = null; var filtered = usersFromDB.AsEnumerable().Where(r => r.Field <string>("isValid").ToLower().Contains(IsValidHSN.ToLower())); HSNList = filtered.Count() > 0 ? filtered.CopyToDataTable() : usersFromDB.Copy(); } } break; } }
public bool SAVE(HSNCode obj) { try { Connect(); SqlCommand cmd = new SqlCommand("IUHSNCodeNew", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CompanyID", HospitalID); cmd.Parameters.AddWithValue("@LocationID", LocationID); if (obj.hsnCodeID == 0) { cmd.Parameters.AddWithValue("@Mode", "ADD"); cmd.Parameters.AddWithValue("@HSNCodeID", 0); } else { cmd.Parameters.AddWithValue("@Mode", "Edit"); cmd.Parameters.AddWithValue("@HSNCodeID", obj.hsnCodeID); } cmd.Parameters.AddWithValue("@HSNCode", obj.hsnCode); if (obj.description == "" || obj.description == null) { cmd.Parameters.AddWithValue("@Description", ""); } else { cmd.Parameters.AddWithValue("@Description", obj.description); } cmd.Parameters.AddWithValue("@Category", obj.taxable); cmd.Parameters.AddWithValue("@TaxBased", "Value"); if (obj.gstRate == "" || obj.gstRate == null) { cmd.Parameters.AddWithValue("@GSTRate", 0); } else { cmd.Parameters.AddWithValue("@GSTRate", obj.gstRate); } cmd.Parameters.AddWithValue("@EffectiveDate", obj.effectiveFrom); cmd.Parameters.AddWithValue("@CreationID", UserID); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (i > 0) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }