Beispiel #1
0
        public ActionResult Updatephongban(string act, string ID, PhongBanModels model)
        {
            if (!IsLogged())
            {
                return(BackToLogin());
            }
            if (act == "create")
            {
                PhongBanModels paramphongban = new PhongBanModels();
                paramphongban.maphongban  = "";
                paramphongban.madonvi     = "1";
                paramphongban.tenphongban = model.tenphongban;
                paramphongban.sodienthoai = model.sodienthoai;

                paramphongban.email   = model.email;
                paramphongban.hovaten = model.hovaten;


                //var lstcaptrentt = lstthongtingiamdoc.Where(p => p.mathongtin == model.thuocquanly).ToList();
                //if (lstcaptrentt.Count > 0)
                //{
                //paramphongban.thuocquanly = model.thuocquanly;
                //paramphongban.hotenquanly = lstcaptrentt[0].hovaten;
                paramphongban.ghichu = model.ghichu;
                //}

                //var lstcaptrentt1 = lstthongtingiamdoc.Where(p => p.mathongtin == model.thuocquanly1).ToList();
                //if (lstcaptrentt1.Count > 0)
                //{
                //paramphongban.thuocquanly1 = model.thuocquanly1;
                //paramphongban.hotenquanly1 = lstcaptrentt1[0].hovaten;
                paramphongban.ghichu1 = model.ghichu1;
                //}

                //var lstcaptrentt2 = lstthongtingiamdoc.Where(p => p.mathongtin == model.thuocquanly2).ToList();
                //if (lstcaptrentt2.Count > 0)
                //{
                //paramphongban.thuocquanly2 = model.thuocquanly2;
                //paramphongban.hotenquanly2 = lstcaptrentt1[0].hovaten;
                paramphongban.ghichu2 = model.ghichu2;
                //}

                paramphongban.cv_thietbi = model.cv_thietbi;
                paramphongban.gs_thietbi = model.gs_thietbi;

                paramphongban.cv_hsse = model.cv_hsse;
                paramphongban.gs_hsse = model.gs_hsse;

                paramphongban.cv_qaqc = model.cv_qaqc;
                paramphongban.gs_qaqc = model.gs_qaqc;

                paramphongban.cv_mep = model.cv_mep;
                paramphongban.gs_mep = model.gs_mep;

                paramphongban.xoa                 = "0";
                paramphongban.nguoitao            = int.Parse(Session["userid"].ToString());
                paramphongban.ngaytao             = ngaytao;
                paramphongban.phongban_congtruong = "1";
                DanhmucServices services = new DanhmucServices();
                string          result   = services.Insert_phongban(paramphongban);
                maphongban = result;
            }
            else if (act == "update")
            {
                PhongBanModels paramphongban = new PhongBanModels();
                FunctionXML    function      = new FunctionXML(Functions.MapPath("~/Xml/Config/encryptionkeyEncodeLink.config"));
                paramphongban.maphongban  = AES.DecryptText(ID, function.ReadXMLGetKeyEncrypt());
                paramphongban.madonvi     = "1";
                paramphongban.tenphongban = model.tenphongban;
                paramphongban.sodienthoai = model.sodienthoai;

                paramphongban.email   = model.email;
                paramphongban.hovaten = model.hovaten;

                //var lstcaptrentt = lstthongtingiamdoc.Where(p => p.mathongtin == model.thuocquanly).ToList();
                //if (lstcaptrentt.Count > 0)
                //
                //paramphongban.thuocquanly = model.thuocquanly;
                //paramphongban.hotenquanly = lstcaptrentt[0].hovaten;
                paramphongban.ghichu = model.ghichu;
                //}

                //var lstcaptrentt1 = lstthongtingiamdoc.Where(p => p.mathongtin == model.thuocquanly1).ToList();
                //if (lstcaptrentt1.Count > 0)
                //{
                //paramphongban.thuocquanly1 = model.thuocquanly1;
                //paramphongban.hotenquanly1 = lstcaptrentt1[0].hovaten;
                paramphongban.ghichu1 = model.ghichu1;
                //}

                //var lstcaptrentt2 = lstthongtingiamdoc.Where(p => p.mathongtin == model.thuocquanly2).ToList();
                //if (lstcaptrentt2.Count > 0)
                //{
                //paramphongban.thuocquanly2 = model.thuocquanly2;
                //paramphongban.hotenquanly2 = lstcaptrentt1[0].hovaten;
                paramphongban.ghichu2 = model.ghichu2;
                //}

                paramphongban.cv_thietbi = model.cv_thietbi;
                paramphongban.gs_thietbi = model.gs_thietbi;

                paramphongban.cv_hsse = model.cv_hsse;
                paramphongban.gs_hsse = model.gs_hsse;

                paramphongban.cv_qaqc = model.cv_qaqc;
                paramphongban.gs_qaqc = model.gs_qaqc;

                paramphongban.cv_mep = model.cv_mep;
                paramphongban.gs_mep = model.gs_mep;

                paramphongban.xoa      = "0";
                paramphongban.nguoitao = int.Parse(Session["userid"].ToString());
                paramphongban.ngaytao  = ngaytao;
                DanhmucServices services = new DanhmucServices();
                string          result   = services.Insert_phongban(paramphongban);
                maphongban = result;
            }
            else if (act == "delete")
            {
                PhongBanModels paramphongban = new PhongBanModels();
                FunctionXML    function      = new FunctionXML(Functions.MapPath("~/Xml/Config/encryptionkeyEncodeLink.config"));
                paramphongban.maphongban     = AES.DecryptText(ID, function.ReadXMLGetKeyEncrypt());
                paramphongban.nguoihieuchinh = int.Parse(Session["userid"].ToString());
                DanhmucServices services = new DanhmucServices();
                string          result   = services.Deleted_phongban(paramphongban.maphongban.ToString(), paramphongban.nguoihieuchinh.ToString());
                maphongban = result;
            }
            return(RedirectToAction("Index", "Danhmuc2"));
        }