Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ms_module ms_module = db.ms_module.Find(id);

            db.ms_module.Remove(ms_module);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public JsonResult PackDelete(int id)
        {
            ms_module _o = db.ms_module.Find(id);

            db.ms_module.Remove(_o);
            db.SaveChanges();
            return(Json("Records deleted successfully.", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "module_id,module_code,module_name,fl_active,created_date,created_by,updated_date,updated_by,deleted_date,deleted_by,org_id,rec_order")] ms_module ms_module)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ms_module).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ms_module));
 }
Ejemplo n.º 4
0
        // GET: module/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ms_module ms_module = db.ms_module.Find(id);

            if (ms_module == null)
            {
                return(HttpNotFound());
            }
            return(View(ms_module));
        }
Ejemplo n.º 5
0
        public JsonResult List(string sidx, string sord, int page, int rows, bool _search, string searchField, string searchOper, string searchString)
        {
            ms_module module = new ms_module();

            sord = (sord == null) ? "" : sord;
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize  = rows;

            var ModuleList = from m in db.ms_module
                             where (m.deleted_date == null)
                             join u in db.ms_user on m.updated_by equals u.user_id
                             into t_joined
                             from row_join in t_joined.DefaultIfEmpty()
                             from usr in db.ms_user.Where(rec_udated_by => (rec_udated_by == null) ? false : rec_udated_by.user_id == row_join.user_id).DefaultIfEmpty()
                             select new
            {
                m.module_id,
                m.module_code,
                m.module_name,
                m.rec_order,
                m.fl_active,
                rec_isactive = (m.fl_active == true) ? "Yes" : "No",
                updated_by   = (usr == null) ? string.Empty : usr.user_name,
                m.updated_date
            };

            // search function
            if (_search)
            {
                switch (searchField)
                {
                case "modul_code":
                    ModuleList = ModuleList.Where(t => t.module_code.Contains(searchString));
                    break;

                case "module_name":
                    ModuleList = ModuleList.Where(t => t.module_name.Contains(searchString));
                    break;
                }
            }
            //calc paging
            int totalRecords = ModuleList.Count();
            var totalPages   = (int)Math.Ceiling((float)totalRecords / (float)rows);

            //default soring
            if (sord.ToUpper() == "DESC")
            {
                ModuleList = ModuleList.OrderByDescending(t => t.module_code);
                ModuleList = ModuleList.Skip(pageIndex * pageSize).Take(pageSize);
            }
            else
            {
                ModuleList = ModuleList.OrderBy(t => t.module_code);
                ModuleList = ModuleList.Skip(pageIndex * pageSize).Take(pageSize);
            }
            var jsonData = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows    = ModuleList
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        public JsonResult CRUDModule()
        {
            if (Request.HttpMethod == "POST")
            {
                ms_module _o = null;
                int       id = 0;
                switch (Request.Form["oper"])
                {
                case "del":
                    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
                        id                 = Convert.ToInt32(values[i]);
                        _o                 = db.ms_module.Find(id);
                        _o.fl_active       = false;
                        _o.deleted_by      = UserProfile.UserId; //userid
                        _o.deleted_date    = DateTime.Now;
                        db.Entry(_o).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    break;

                case "add":
                    _o             = new ms_module();
                    _o.module_code = Request.Form["module_code"];
                    _o.module_name = Request.Form["module_name"];
                    _o.fl_active   = Request.Form["rec_isactive"].ToLower().Equals("yes");
                    _o.rec_order   = Convert.ToInt32(Request.Form["rec_order"]);

                    _o.created_by      = UserProfile.UserId;
                    _o.created_date    = DateTime.Now;
                    _o.updated_by      = UserProfile.UserId;
                    _o.updated_date    = DateTime.Now;
                    _o.org_id          = UserProfile.OrgId;
                    _o.deleted_by      = null;
                    _o.deleted_date    = null;
                    db.Entry(_o).State = EntityState.Added;
                    db.SaveChanges();
                    break;

                case "edit":
                    bool boolNumeric = Int32.TryParse(Request.Form["module_id"], out id);
                    if (boolNumeric)         //update
                    {
                        //id = Convert.ToInt32(Request.Form["module_id"]);
                        _o             = db.ms_module.Find(id);
                        _o.module_code = Request.Form["module_code"];
                        _o.module_name = Request.Form["module_name"];
                        _o.fl_active   = Request.Form["rec_isactive"].ToLower().Equals("yes");
                        _o.rec_order   = Convert.ToInt32(Request.Form["rec_order"]);

                        _o.updated_by      = UserProfile.UserId;
                        _o.updated_date    = DateTime.Now;
                        _o.org_id          = UserProfile.OrgId;
                        _o.deleted_by      = null;
                        _o.deleted_date    = null;
                        db.Entry(_o).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    else     //add
                    {
                        _o             = new ms_module();
                        _o.module_code = Request.Form["module_code"];
                        _o.module_name = Request.Form["module_name"];
                        _o.fl_active   = Request.Form["rec_isactive"].ToLower().Equals("yes");
                        _o.rec_order   = Convert.ToInt32(Request.Form["rec_order"]);

                        _o.created_by      = UserProfile.UserId;
                        _o.created_date    = DateTime.Now;
                        _o.updated_by      = UserProfile.UserId;
                        _o.updated_date    = DateTime.Now;
                        _o.org_id          = UserProfile.OrgId;
                        _o.deleted_by      = null;
                        _o.deleted_date    = null;
                        db.Entry(_o).State = EntityState.Added;
                        db.SaveChanges();
                    }
                    break;

                default:
                    break;
                }
                return(Json("Records successfully saved.", JsonRequestBehavior.AllowGet));
            }
            return(Json("Invalid requests"));
        }