public bool UpdateKUnit(K_Unit unit) { string sql = " Update KI_Unit set UnitName=@UnitName, UnitCode=@UnitCode, " + " OrganizationId=@OrganizationId, " + " EnteredBy=@EnteredBy, EnteredDate=@EnteredDate,LastUpdatedBy=@LastUpdatedBy, " + " LastUpdatedDate=@LastUpdatedDate, IsDeleted=0, DeletedBy=0, DeletedDate=null" + " where UnitId=@UnitId"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql, unit); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
public bool InsertKUnit(K_Unit unit) { string sql = " Insert into KI_Unit (UnitName, UnitCode,OrganizationId, EnteredBy, EnteredDate," + " LastUpdatedBy, LastUpdatedDate, IsDeleted, DeletedBy, DeletedDate) " + " values " + "(@UnitName, @UnitCode,@OrganizationId, @EnteredBy, @EnteredDate," + " 0, null, 0, 0, null)"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql, unit); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
// GET: Unit/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } K_Unit k_Unit = db.GetKUnitById((int)id); if (k_Unit == null) { return(HttpNotFound()); } return(View(k_Unit)); }
public ActionResult Edit(FormCollection frm) { var ses = sesrepo.GetSessionById((User as CustomPrincipal).UserId); int orgid = ses.OrganizationId; K_Unit k_Unit = db.GetKUnitById(Convert.ToInt32(frm["UnitId"])); k_Unit.UnitName = frm["UnitName"]; // mS_Unit.UnitCode = frm["UnitCode"]; k_Unit.OrganizationId = orgid; k_Unit.LastUpdatedBy = (User as CustomPrincipal).UserId; k_Unit.LastUpdatedDate = DateTime.Now; if (ModelState.IsValid) { db.UpdateKUnit(k_Unit); return(RedirectToAction("Index")); } return(View(k_Unit)); }
public ActionResult Create(FormCollection frm) { var ses = sesrepo.GetSessionById((User as CustomPrincipal).UserId); int orgid = ses.OrganizationId; K_Unit k_Unit = new K_Unit(); k_Unit.UnitName = frm["UnitName"]; //mS_Unit.UnitCode = frm["UnitCode"]; k_Unit.OrganizationId = orgid; k_Unit.EnteredBy = (User as CustomPrincipal).UserId; k_Unit.EnteredDate = DateTime.Now; if (ModelState.IsValid) { db.InsertKUnit(k_Unit); return(RedirectToAction("Index")); } return(View(k_Unit)); }