public bool UpdateAssetItem(FA_AssetItem item) { string sql = " Update FA_AssetItem set AssetCategoryId=@AssetCategoryId,AssetName=@AssetName, " + " AssetCode=@AssetCode,OrganizationId=@OrganizationId,LifeSpan=@LifeSpan, " + " LastUpdatedBy=@LastUpdatedBy,LastUpdatedDate=@LastUpdatedDate, " + "WarrentyDuration=@WarrentyDuration,FromDate=@FromDate," + "FromDateBS=@FromDateBS,ToDate=@ToDate,ToDateBS=@ToDateBS, IsWarranty=@IsWarranty" + " where AssetItemId= @AssetItemId"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql, item); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
public bool InsertAssetItem(FA_AssetItem item) { string sql = " Insert into FA_AssetItem ( AssetCategoryId,AssetName,AssetCode,OrganizationId,LifeSpan,IsDepreciation," + " EnteredBy,EnteredDate,LastUpdatedBy,LastUpdatedDate,IsDeleted,DeletedBy,DeletedDate,WarrentyDuration,FromDate,FromDateBS,ToDate," + "ToDateBS, IsWarranty) " + " values " + "( @AssetCategoryId,@AssetName,@AssetCode,@OrganizationId,@LifeSpan,@IsDepreciation," + "@EnteredBy,@EnteredDate,0,null,0,0,null,@WarrentyDuration,@FromDate,@FromDateBS,@ToDate,@ToDateBS,@IsWarranty)"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql, item); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
public ActionResult Create(FormCollection frm) { var ses = sesrepo.GetSessionById((User as CustomPrincipal).UserId); int orgid = ses.OrganizationId; FA_AssetItem item = new FA_AssetItem(); item.AssetName = frm["AssetName"]; item.AssetCode = frm["AssetCode"]; item.OrganizationId = orgid; item.AssetCategoryId = Convert.ToInt32(frm["AssetCategoryId"]); if (frm["IsWarranty"] != "No") { item.LifeSpan = Convert.ToDecimal(frm["LifeSpan"]); item.WarrentyDuration = Convert.ToInt32(frm["WarrentyDuration"]); //item.WarrentyIndate = Convert.ToDateTime(frm["WarrentyIndate"]); item.FromDate = DateTime.ParseExact(frm["FromDate"], "yyyy-MM-dd", null); item.FromDateBS = frm["FromDateBS"]; item.ToDate = DateTime.ParseExact(frm["ToDate"], "yyyy-MM-dd", null); item.ToDateBS = frm["ToDateBS"]; item.IsWarranty = true; } else { item.WarrentyDuration = 0; item.WarrentyIndate = null; item.LifeSpan = 0; item.FromDate = null; item.FromDateBS = null; item.ToDate = null; item.ToDateBS = null; item.IsWarranty = false; } item.IsDepreciation = true; item.IsDeleted = false; item.EnteredBy = (User as CustomPrincipal).UserId; item.EnteredDate = DateTime.Now; if (ModelState.IsValid) { db.InsertAssetItem(item); return(RedirectToAction("Index")); } ViewBag.AssetCategoryId = new SelectList(ddl.GetAssetCategoryList(orgid), "Id", "Name", item.AssetCategoryId); return(View(item)); }
// GET: Category/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var ses = sesrepo.GetSessionById((User as CustomPrincipal).UserId); int orgid = ses.OrganizationId; FA_AssetItem item = db.GetAssetItemById((int)id); if (item == null) { return(HttpNotFound()); } ViewBag.AssetCategoryId = new SelectList(ddl.GetAssetCategoryList(orgid), "Id", "Name", item.AssetCategoryId); return(View(item)); }