コード例 #1
0
        public ActionResult Delete()
        {
            this.SaveAccessLog("delete");
            if (Session["IsAdmin"] == null)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            string id     = this.HttpContext.Request["departid"];
            int    output = 0;

            try
            {
                this.SetConnectionDB();



                DepartmentServices services = new DepartmentServices(this.DBConnection);
                if (services.ERROR != null)
                {
                    throw new Exception(services.ERROR);
                }
                output = services.Delete(Int32.Parse(id));
            }
            catch (Exception ex)
            {
                FileHelper.SaveFile(new { data = id, ERROR = ex }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt");
                output = -2;
            }
            //*************************************XU LY VAN DE THONG BAO THANH CONG HAY THAT BAI********************
            this.GetLanguage();
            BlockDepartmentCreateLangModel blockLang = new BlockDepartmentCreateLangModel();

            blockLang.BlockName = "block_department_list";
            blockLang.SetLanguage(this.LANGUAGE_OBJECT);

            Session["msg_code"] = output;
            if (output > 1)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_department_list.success_delete", this.LANGUAGE_OBJECT);
            }

            return(RedirectToAction("List"));
        }
コード例 #2
0
        public ActionResult Create(EntityDepartmentModel model)
        {
            if (null == Session[this.SESSION_NAME_USERID])
            {
                return(RedirectToAction("Login", "Home"));
            }

            if (Session["IsAdmin"] == null)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            this.SetConnectionDB();

            this.GetLanguage();
            int output = 0;

            if (model.Code == null)
            {
                Session["msg_code"] = -1;
                Session["msg_text"] = BlockLanguageModel.GetElementLang(this.LANGUAGE_OBJECT, "messages.block_department_create.error_code");
                TempData["data"]    = model;
                return(RedirectToAction("Create"));
            }
            model.Code = model.Filter01.Substring(0, 2);
            DepartmentServices departServices = new DepartmentServices(this.DBConnection);

            output = departServices.CreateDepart(model);

            /****************************************RESPONSE FAILE OR SUCCESS******************************************/

            //this.GetLanguage();
            BlockDepartmentCreateLangModel blockLang = new BlockDepartmentCreateLangModel();

            blockLang.BlockName = "block_department_create";
            blockLang.SetLanguage(this.LANGUAGE_OBJECT);
            Session["msg_text"] = blockLang.GetMessage(output);
            Session["msg_code"] = output;

            if (departServices.ERROR != null)
            {
                BI_Project.Helpers.FileHelper.SaveFile(departServices.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt");
            }

            if (model.DepartId > 0 && output > 0)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_department_create.success_edit", this.LANGUAGE_OBJECT);
            }
            if (output == 0)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_department_create.error_business_1", this.LANGUAGE_OBJECT);
                //return RedirectToAction("Create?roleid=" + model.RoleId);
            }
            if (output > 0)
            {
                return(RedirectToAction("List"));
            }


            TempData["data"] = model;
            return(RedirectToAction("Create"));
        }