public void EditInventorySales(INV_SalesBill asales) { string sql = " update INV_SalesBill set " + " DepartmentId=@DepartmentId,VendorId=@VendorId, BillNo=@BillNo, BillDate=@BillDate, BillDateBS=@BillDateBS," + " TotalAmount=@TotalAmount, " + " VatApplicable=@VatApplicable,VatAmount=@VatAmount,VATPercent=@VATPercent," + " DiscountAmount=@DiscountAmount,DiscountPercent=@DiscountPercent,TaxableAmount=@TaxableAmount,TotalWithVat=@TotalWithVat," + " LastUpdatedBy=@LastUpdatedBy, LastUpdatedDate=@LastUpdatedDate,Remarks=@Remarks" + " where PurchaseBillId=@PurchaseBillId"; using (var db = DbHelper.GetDBConnection()) { db.Query(sql, asales); db.Close(); } }
public int AddInventorySales(INV_SalesBill asales) { string sql = " insert into INV_SalesBill (" + " DepartmentId,VendorId, BillNo, BillDate, BillDateBS, TotalAmount,VatApplicable,VatPercent,VatAmount, IsVerified,Remarks," + " DiscountAmount,DiscountPercent,TaxableAmount,TotalWithVat,VerifiedBy, VerifiedDate, EnteredBy, EnteredDate, LastUpdatedBy, LastUpdatedDate, IsDeleted, DeletedBy," + " DeletedDate, BillSerialNo" + ")" + " values " + " (" + "@DepartmentId,@VendorId, @BillNo, @BillDate, @BillDateBS, @TotalAmount, @VatApplicable,@VatPercent,@VatAmount, @IsVerified,@Remarks," + " @DiscountAmount,@DiscountPercent,@TaxableAmount,@TotalWithVat,@VerifiedBy, @VerifiedDate, @EnteredBy, @EnteredDate, 0, null, 0, 0," + " null, @BillSerialNo" + ") SELECT CAST(SCOPE_IDENTITY() as int)"; using (var db = DbHelper.GetDBConnection()) { int a = db.Query <int>(sql, asales).SingleOrDefault(); db.Close(); return(a); } }
public ActionResult Create() { INV_SalesBill sn = (db.GetBillSerialNo()); if (sn == null) { ViewBag.BSN = 1; } else { int sn1 = Convert.ToInt32(sn.BillSerialNo) + 1; ViewBag.BSN = sn1; } int depid = Convert.ToInt32(Session["DepartmentId"]); ViewBag.VendorId = new SelectList(ddl.getVendorList(depid), "Id", "Name"); ViewBag.CategoryList = new SelectList(ddl.getCategoryList(depid), "Id", "Name"); ViewBag.CategoryId = new SelectList(ddl.getCategoryList(depid), "Id", "Name"); ViewBag.ItemList = new SelectList(ddl.getItemList(depid), "Id", "Name"); ViewBag.ItemId = new SelectList(ddl.getItemList(depid), "Id", "Name"); return(View()); }
//[ValidateAntiForgeryToken] public ActionResult Create(FormCollection frm, string[] hddrowindex) { int depid = Convert.ToInt32(Session["DepartmentId"]); int uid = Convert.ToInt32(Session["UserId"]); var cdate = DateTime.Now; int salesid = 0; int totalcount = Convert.ToInt32(frm["hddrowindex"]); try { //For bill Section INV_SalesBill pbill = new INV_SalesBill(); pbill.BillDate = frm["BillDate"]; pbill.BillDateBS = frm["BillDateBS"]; pbill.BillNo = frm["BillNo"]; pbill.BillSerialNo = Convert.ToInt32(frm["BillSerialNo"]); pbill.VendorId = Convert.ToInt32(frm["VendorId"]); pbill.Remarks = frm["Remarks"]; pbill.DepartmentId = depid; pbill.EnteredBy = uid; pbill.EnteredDate = cdate; pbill.IsVerified = 1; pbill.VerifiedBy = uid; pbill.VerifiedDate = cdate; pbill.IsDeleted = false; pbill.TotalAmount = Convert.ToDecimal(frm["TotalAmount"]); pbill.TotalWithVat = Convert.ToDecimal(frm["TotalWithVat"]); pbill.DiscountPercent = Convert.ToInt32(frm["DiscountPercent"]); pbill.DiscountAmount = Convert.ToDecimal(frm["DiscountAmount"]); pbill.TaxableAmount = Convert.ToDecimal(frm["TaxableAmount"]); if (frm["VatApplicable"] == "Yes") { pbill.VatApplicable = 1; pbill.VatAmount = Convert.ToDecimal(frm["VatAmount"]); pbill.VatPercent = Convert.ToInt32(frm["VatPercent"]); } else { pbill.VatApplicable = 0; pbill.VatAmount = 0; pbill.VatPercent = 0; } salesid = db.AddInventorySales(pbill); //Purchase Item Add if (hddrowindex != null) { for (int i = 1; i <= totalcount; i++) { if (i == Convert.ToInt32(frm["" + i])) { INV_SalesItem pitem = new INV_SalesItem(); pitem.DepartmentId = depid; pitem.SalesBillId = salesid; pitem.ItemId = Convert.ToInt32(frm["ItemId-" + i]); pitem.SalesQuantity = Convert.ToDecimal(frm["Quantity-" + i]); pitem.Rate = Convert.ToDecimal(frm["Rate-" + i]); pitem.Total = Convert.ToDecimal(frm["Total-" + i]); pitem.IsVerified = true; pitem.VerifiedBy = uid; pitem.VerifiedDate = cdate; pitem.IsDeleted = false; pitem.EnteredBy = uid; pitem.EnteredDate = cdate; db.AddInventorySalesItem(pitem); } } } return(RedirectToAction("Index")); } catch (Exception ex) { //int depid = Convert.ToInt32(Session["DepartmentId"]); ViewBag.VendorId = new SelectList(ddl.getVendorList(depid), "Id", "Name"); ViewBag.CategoryList = new SelectList(ddl.getAssetCategoryList(depid), "Id", "Name"); ViewBag.CategoryId = new SelectList(ddl.getAssetCategoryList(depid), "Id", "Name"); ViewBag.ItemList = new SelectList(ddl.getItemList(depid), "Id", "Name"); ViewBag.ItemId = new SelectList(ddl.getItemList(depid), "Id", "Name"); return(View()); } }