Beispiel #1
0
        public bool updateERAPermissionForInf(long id, Dictionary <string, object> dicObj)
        {
            bool ret = false;

            using (NaNaEntities db = new NaNaEntities()) {
                ERAPermissionForInf e = db.ERAPermissionForInf.AsQueryable().FirstOrDefault(x => x.Id == id);

                //不存在此資料
                if (e == null)
                {
                    return(false);
                }

                Type cl = e.GetType();

                foreach (var obj in dicObj)
                {
                    if (cl.GetProperty(obj.Key) != null)
                    {
                        cl.GetProperty(obj.Key).SetValue(e, obj.Value);
                    }
                }

                db.SaveChanges();
                ret = true;
            }

            return(ret);
        }
Beispiel #2
0
        //ERAPermissionForInf
        public ERAPermissionForInf addERAPermissionForInf(ERAPermissionForInf e)
        {
            ERAPermissionForInf ret = null;

            using (NaNaEntities db = new NaNaEntities()) {
                ret = db.ERAPermissionForInf.Add(e);
                db.SaveChanges();
            }

            return(ret);
        }
        public FormOptionsSettingViewModel.ERAPermissionForInfResult addERAPermissionForInf(ERAPermissionForInf e)
        {
            FormOptionsSettingViewModel.ERAPermissionForInfResult ret = new FormOptionsSettingViewModel.ERAPermissionForInfResult();
            try
            {
                ret.success    = this.formOptionSettingDao.addERAPermissionForInf(e) != null;
                ret.resultCode = "200";
            }
            catch (Exception ex)
            {
                ret.success         = false;
                ret.resultException = ex.ToString();
                ret.resultCode      = "500";
            }

            return(ret);
        }
 public ERAPermissionForInfResult() : base()
 {
     this.setting = null;
 }
        protected void btn_formClassSettingForInfoSystemApply_add_Click(object sender, EventArgs e)
        {
            this.lt_akert_msg.Text = "";

            //新增時判斷DB是否有此項資料(目前作法判斷項目名稱,只要名稱重複.一律不能新增(已存在).即使是同名稱不同人不同層級)
            FormOptionsSettingViewModel.FormClassSettingForInfoSystemApplyQueryParameter param = new FormOptionsSettingViewModel.FormClassSettingForInfoSystemApplyQueryParameter()
            {
                desc                 = true,
                orderField           = "Id",
                pageIndex            = 1,
                pageSize             = int.MaxValue,
                personnelID          = this.hid_formClassSettingForInfoSystemApply_personnelID.Value,
                name                 = this.txt_formClassSettingForInfoSystemApply_className.Text.ToString().Trim(),
                departmentID         = this.hid_departmentID.Value,
                dicisionProcessLevel = this.ddl_formClassSettingForInfoSystemApply_dicisionProcessLevel.SelectedValue
            };

            FormOptionsSettingViewModel.ERACategoryForInfListResult list_ret = this.formOptSvc.getERACategoryForInfListResult(param);

            if (list_ret.count > 0)
            {
                this.lt_akert_msg.Text = UtilitySvc.alertMsg("此類別已存在");
                return;
            }

            //新增ERACategoryForInf項目作法
            long pID = 0;

            if (this.ddl_formClassSettingForInfoSystemApply_parentID.SelectedValue == "-")
            {
                pID = -1;//代表父類別
            }
            else
            {
                pID = long.Parse(this.ddl_formClassSettingForInfoSystemApply_parentID.SelectedValue);//子類別parentID欄位抓取父類別ID
            }

            ERACategoryForInf ec = new ERACategoryForInf()
            {
                parentID               = pID,
                name                   = this.txt_formClassSettingForInfoSystemApply_className.Text,
                departmentID           = this.hid_departmentID.Value,
                personnelID            = this.hid_formClassSettingForInfoSystemApply_personnelID.Value,
                dicisionProcessLevel   = this.ddl_formClassSettingForInfoSystemApply_dicisionProcessLevel.SelectedValue,
                deleted                = false,
                DateCreated            = DateTime.Now,
                addActivityPersonnelID = this.hid_formClassSettingForInfoSystemApply_ActivityPersonnelID.Value
            };

            FormOptionsSettingViewModel.ERACategoryForInfResult add_ret_ERAC = this.formOptSvc.addERACategoryForInf(ec);

            //新增ERAPermissionForInf項目作法
            long iERACategoryID = ec.Id;    //ERAPermissionForInf.ERACategoryID
            bool bIsforAll      = true;

            if (this.ddl_formClassSettingForInfoSystemApply_isforAll.SelectedValue == "0")
            {
                bIsforAll = false;
            }

            ERAPermissionForInf ep = new ERAPermissionForInf()
            {
                ERACategoryID = iERACategoryID,
                isforAll      = bIsforAll,
                enable        = true,
                departmentID  = this.ddl_PermissionDepartmentID.SelectedValue,
                deleted       = false,
                DateCreated   = DateTime.Now
            };

            FormOptionsSettingViewModel.ERAPermissionForInfResult add_ret_ERAP = this.formOptSvc.addERAPermissionForInf(ep);

            if (add_ret_ERAC.success || add_ret_ERAP.success)
            {
                this.lt_akert_msg.Text = UtilitySvc.alertMsg("新增成功");
            }
            else
            {
                this.lt_akert_msg.Text = UtilitySvc.alertMsg(add_ret_ERAC.resultException) + UtilitySvc.alertMsg(add_ret_ERAP.resultException);
            }

            this.reload();
        }