public ActionResult create(FormCollection frm) { int depid = Convert.ToInt32(Session["DepartmentId"]); int uid = Convert.ToInt32(Session["UserId"]); var cdate = DateTime.Now; A_Asset asset = new A_Asset(); asset.DepartmentId = Convert.ToInt32(frm["DepartmentId1"]); asset.LocationId = Convert.ToInt32(frm["LocationId"]); asset.AssetItemId = Convert.ToInt32(frm["AssetItemId"]); asset.AssetUniqueCode = frm["AssetUniqueCodeDep"] + "-" + frm["AssetUniqueCodeLoc"] + "-" + frm["AssetUniqueCodeItem"]; asset.AssetDate = frm["AssetDate"]; asset.AssetDateBS = frm["AssetDateBS"]; asset.Description = frm["Description"]; //asset.Remarks = frm["Remarks"]; asset.UsefullLife = Convert.ToInt32(frm["UsefullLife"]); if (frm["IsDepreciationApplicable"] == "Yes") { asset.IsDepreciationApplicable = true; asset.DepreciationStartDate = frm["DepreciationDate"]; asset.DepreciationStartDateBS = frm["DepreciationDateBS"]; asset.DepreciationRemarks = frm["DepreciationRemarks"]; } else { asset.IsDepreciationApplicable = false; asset.DepreciationStartDate = null; asset.DepreciationStartDateBS = null; asset.DepreciationRemarks = string.Empty;// frm["DepreciationRemarks"]; } if (frm["IsScrap"] == "Yes") { asset.IsScrap = true; asset.ScrapDate = frm["ScrapDate"]; asset.ScrapDateBS = frm["ScrapDateBS"]; asset.ScrapRealizedValue = Convert.ToDecimal(frm["ScrapRealizeValue"]); } else { asset.IsScrap = false; asset.ScrapDate = null; asset.ScrapDateBS = null; asset.ScrapRealizedValue = 0; } asset.EnteredBy = uid; asset.EnteredDate = cdate; asset.IsDeleted = false; db.AddAsset(asset); return(RedirectToAction("Index")); }
public bool UpdateAsset(A_Asset updateAsset, int Id) { string sql = " Update A_Asset set AssetDate=@AssetDate, AssetDateBS=@AssetDateBS, Description=@Description,UsefullLife=@UsefullLife," + "IsDepreciationApplicable=@IsDepreciationApplicable, DepreciationStartDate=@DepreciationStartDate, DepreciationStartDateBS=@DepreciationStartDateBS, DepreciationRemarks=@DepreciationRemarks," + "IsScrap=@IsScrap, ScrapDate=@ScrapDate, ScrapDateBS=@ScrapDateBS, ScrapRealizedValue=@ScrapRealizedValue, " + "LastUpdatedDate=@LastUpdatedDate, LastUpdatedBy=@LastUpdatedBy where IsDeleted=0 and AssetId= " + Id; using (var db = DbHelper.GetDBConnection()) { var lst = db.Execute(sql, updateAsset); db.Close(); if (lst > 0) { return(true); } else { return(false); } } }
public int AddAsset(A_Asset asset) { string sql = " insert into A_Asset(" + " DepartmentId, LocationId, AssetItemId, AssetUniqueCode, AssetDate, AssetDateBS,Description,UsefullLife," + " IsDepreciationApplicable,DepreciationStartDate,DepreciationStartDateBS,DepreciationRemarks," + " IsScrap,ScrapDate,ScrapDateBS,ScrapRealizedValue," + " EnteredBy, EnteredDate, LastUpdatedBy, LastUpdatedDate, IsDeleted," + " DeletedDate, DeletedBy" + ")" + " values(" + "@DepartmentId, @LocationId, @AssetItemId, @AssetUniqueCode, @AssetDate, @AssetDateBS, @Description, @UsefullLife," + " @IsDepreciationApplicable, @DepreciationStartDate,@DepreciationStartDateBS,@DepreciationRemarks," + " @IsScrap, @ScrapDate, @ScrapDateBS, @ScrapRealizedValue," + " @EnteredBy, @EnteredDate, 0, null, 0," + " null, 0 " + ") SELECT CAST(SCOPE_IDENTITY() as int)"; using (var db = DbHelper.GetDBConnection()) { int a = db.Query <int>(sql, asset).SingleOrDefault(); db.Close(); return(a); } }
public ActionResult create1(FormCollection frm) { int depid = Convert.ToInt32(Session["DepartmentId"]); int uid = Convert.ToInt32(Session["UserId"]); var cdate = DateTime.Now; int reqQuantity = Convert.ToInt32(frm["RequestQuantity"]); string[] itemCodeSplit = frm["AssetUniqueCodeItem"].Split('-'); string itemCode = itemCodeSplit[0]; int itemCodeNo = Convert.ToInt32(itemCodeSplit[1]); int tokenId = Convert.ToInt32(frm["TokenId"]); for (int i = 0; i < reqQuantity; i++) { A_Asset asset = new A_Asset(); asset.DepartmentId = Convert.ToInt32(frm["DepartmentId1"]); asset.LocationId = Convert.ToInt32(frm["LocationId"]); asset.AssetItemId = Convert.ToInt32(frm["AssetItemId"]); asset.AssetUniqueCode = frm["AssetUniqueCodeDep"] + "-" + frm["AssetUniqueCodeLoc"] + "-" + itemCode + "-" + (itemCodeNo + i); asset.AssetDate = frm["AssetDate"]; asset.AssetDateBS = frm["AssetDateBS"]; asset.Description = frm["Description"]; //asset.Remarks = frm["Remarks"]; asset.UsefullLife = Convert.ToInt32(frm["UsefullLife"]); if (frm["IsDepreciationApplicable"] == "Yes") { asset.IsDepreciationApplicable = true; asset.DepreciationStartDate = frm["DepreciationDate"]; asset.DepreciationStartDateBS = frm["DepreciationDateBS"]; asset.DepreciationRemarks = frm["DepreciationRemarks"]; } else { asset.IsDepreciationApplicable = false; asset.DepreciationStartDate = null; asset.DepreciationStartDateBS = null; asset.DepreciationRemarks = string.Empty;// frm["DepreciationRemarks"]; } if (frm["IsScrap"] == "Yes") { asset.IsScrap = true; asset.ScrapDate = frm["ScrapDate"]; asset.ScrapDateBS = frm["ScrapDateBS"]; asset.ScrapRealizedValue = Convert.ToDecimal(frm["ScrapRealizeValue"]); } else { asset.IsScrap = false; asset.ScrapDate = null; asset.ScrapDateBS = null; asset.ScrapRealizedValue = 0; } asset.EnteredBy = uid; asset.EnteredDate = cdate; asset.IsDeleted = false; db.AddAsset(asset); } db.ApprovedRequestTokenStore(tokenId, uid, cdate); return(RedirectToAction("Index")); }