private string MutationNumberNew(int?asset_id) { tr_asset_registration tr_asset = db.tr_asset_registration.Find(asset_id); ms_asmin_company company = db.ms_asmin_company.Find(tr_asset.company_id); ms_department department = db.ms_department.Find(tr_asset.department_id); ms_asset_category category = db.ms_asset_category.Find(tr_asset.category_id); string code = string.Empty; code += "M"; code += company.company_code; code += department.department_code; code += category.category_code; code += DateTime.Today.Year; code += DateTime.Today.Month.ToString().PadLeft(2, '0'); var _lastno = (from dr in db.tr_disposal_request where dr.disposal_number.Contains(code) orderby dr.request_id descending select dr).ToList <tr_disposal_request>(); if (_lastno.Count > 0) { tr_disposal_request lastno = _lastno.FirstOrDefault(); string currentno = (Convert.ToInt32(lastno.disposal_number.Substring((lastno.disposal_number.Length - 2), 2)) + 1).ToString(); code += currentno.PadLeft(2, '0'); } else { code += "01"; } code += "-"; code += tr_asset.asset_number.Substring((tr_asset.asset_number.Length - 2), 2); return(code); }
public ActionResult DeleteConfirmed(int id) { ms_asset_category ms_asset_category = db.ms_asset_category.Find(id); db.ms_asset_category.Remove(ms_asset_category); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "category_id,category_code,category_name,fl_active,created_date,created_by,updated_date,updated_by,deleted_date,deleted_by,org_id")] ms_asset_category ms_asset_category) { if (ModelState.IsValid) { db.Entry(ms_asset_category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ms_asset_category)); }
public ActionResult Create([Bind(Include = "category_id,category_code,category_name,fl_active,created_date,created_by,updated_date,updated_by,deleted_date,deleted_by,org_id")] ms_asset_category ms_asset_category) { if (ModelState.IsValid) { db.ms_asset_category.Add(ms_asset_category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ms_asset_category)); }
// GET: asset_category/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ms_asset_category ms_asset_category = db.ms_asset_category.Find(id); if (ms_asset_category == null) { return(HttpNotFound()); } return(View(ms_asset_category)); }
public JsonResult CrudCategory() { if (UserProfile.UserId != 0) { if (Request.Form["oper"] == "add") { //prepare for insert data ms_asset_category ms_asset_category = new ms_asset_category(); ms_asset_category.category_code = Request.Form["category_code"]; ms_asset_category.category_name = Request.Form["category_name"]; ms_asset_category.fl_active = Request.Form["rec_isactive"] == "Yes" ? true : false; ms_asset_category.created_by = UserProfile.UserId; ms_asset_category.created_date = DateTime.Now; ms_asset_category.updated_by = UserProfile.UserId; ms_asset_category.updated_date = DateTime.Now; ms_asset_category.org_id = UserProfile.OrgId; ms_asset_category.deleted_by = null; ms_asset_category.deleted_date = null; db.Entry(ms_asset_category).State = EntityState.Added; db.SaveChanges(); return(Json("Insert", JsonRequestBehavior.AllowGet)); } else if (Request.Form["oper"] == "edit") { if (IsNumeric(Request.Form["category_id"].ToString())) { //prepare for update data int id = Convert.ToInt32(Request.Form["category_id"]); ms_asset_category ms_asset_category = db.ms_asset_category.Find(id); ms_asset_category.category_code = Request.Form["category_code"]; ms_asset_category.category_name = Request.Form["category_name"]; ms_asset_category.fl_active = Request.Form["rec_isactive"] == "Yes" ? true : false; ms_asset_category.updated_by = UserProfile.UserId; ms_asset_category.updated_date = DateTime.Now; db.Entry(ms_asset_category).State = EntityState.Modified; db.SaveChanges(); return(Json("Update", JsonRequestBehavior.AllowGet)); } else { //prepare for insert data ms_asset_category ms_asset_category = new ms_asset_category(); ms_asset_category.category_code = Request.Form["category_code"]; ms_asset_category.category_name = Request.Form["category_name"]; ms_asset_category.fl_active = Request.Form["rec_isactive"] == "Yes" ? true : false; ms_asset_category.created_by = UserProfile.UserId; ms_asset_category.created_date = DateTime.Now; ms_asset_category.updated_by = UserProfile.UserId; ms_asset_category.updated_date = DateTime.Now; ms_asset_category.org_id = UserProfile.OrgId; ms_asset_category.deleted_by = null; ms_asset_category.deleted_date = null; db.Entry(ms_asset_category).State = EntityState.Added; //db.ms_asset_category.Add(ms_asset_category); db.SaveChanges(); return(Json("Insert", JsonRequestBehavior.AllowGet)); } } else { if (Request.Form["oper"] == "del") { //for delete process string ids = Request.Form["id"]; string[] values = ids.Split(','); for (int i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); //prepare for soft delete data int id = Convert.ToInt32(values[i]); ms_asset_category ms_asset_category = db.ms_asset_category.Find(id); ms_asset_category.fl_active = false; ms_asset_category.deleted_by = UserProfile.UserId; ms_asset_category.deleted_date = DateTime.Now; db.Entry(ms_asset_category).State = EntityState.Modified; db.SaveChanges(); } return(Json("Delete", JsonRequestBehavior.AllowGet)); } else { return(Json("Error", JsonRequestBehavior.AllowGet)); } } } else { return(Json("Session", JsonRequestBehavior.AllowGet)); } }