Ejemplo n.º 1
0
    protected void imbSave_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        string EditFlag = hidEditFlag.Value.Trim();


        //定义Model变量
        DeptQuarterModel model = new DeptQuarterModel();

        //编辑标识
        model.EditFlag = EditFlag;
        string codeRules = string.Empty;
        //获取编号
        string quarterNo = string.Empty;

        if (!EditFlag.Equals("INSERT"))
        {
            //quarterNo = txtDisplayCode.Value.Trim();
            quarterNo = hfdNo.Value;
        }
        else
        {
            //获取编码规则ID
            codeRules = codeRule.GetCodeRuleID();
            //手工输入的时候
            if (codeRules == string.Empty)
            {
                quarterNo = codeRule.GetDisplaycode();
            }
        }

        //新建时
        if (ConstUtil.EDIT_FLAG_INSERT.Equals(model.EditFlag))
        {
            //编号为空时,通过编码规则编号获取编号
            if (string.IsNullOrEmpty(quarterNo))
            {
                //获取编码规则编号
                string codeRuleID = codeRule.GetCodeRuleID();
                //通过编码规则代码获取编号
                quarterNo = ItemCodingRuleBus.GetCodeValue(codeRuleID, ConstUtil.CODING_RULE_TABLE_DEPTQUARTER
                                                           , ConstUtil.CODING_RULE_COLUMN_DEPTQUARTER_NO);
            }
            //判断是否存在
            bool isAlready = PrimekeyVerifyBus.CheckCodeUniq(ConstUtil.CODING_RULE_TABLE_DEPTQUARTER
                                                             , ConstUtil.CODING_RULE_COLUMN_DEPTQUARTER_NO, quarterNo);
            //存在的场合
            if (!isAlready)
            {
                lblErrorMes.Visible = true;
                lblErrorMes.Text    = "该编号已被使用,请输入未使用的编号!";

                return;
            }
            else
            {
                lblErrorMes.Visible = false;
                lblErrorMes.Text    = " ";
            }
        }
        //设置岗位编号
        model.QuarterNo = quarterNo;


        //所属机构
        model.DeptID = txtDeptID.Value.Trim();
        //上级岗位
        model.SuperQuarterID = hidSuperQuarter.Value.Trim();
        //岗位名称
        model.QuarterName = txtQuarterName.Text.Trim();
        //拼音代码
        model.PYShort = txtPYShort.Text.Trim();
        //是否关键岗位
        model.KeyFlag = ddlKeyFlag.SelectedValue;
        //岗位分类
        model.TypeID = ddlQuarterType.SelectedValue;
        //岗位级别
        model.LevelID = ddlQuarterLevel.SelectedValue;
        //描述信息
        model.Description = txtDescription.Text.Trim();;
        //启用状态
        model.UsedStatus = ddlUsedStatus.SelectedValue;
        //附件
        model.Attachment     = hfAttachment.Value.Trim();
        model.PageAttachment = hfPageAttachment.Value.Trim();
        //岗位职责
        model.Duty = txtDuty.Text.Trim();
        //任职资格
        model.DutyRequire = txtDutyRequire.Text.Trim();

        //
        model.QuterContent = FCKeditor1.Value;



        bool isSucce = DeptQuarterBus.SaveDeptQuarterInfo(model);

        //保存成功时
        if (isSucce)
        {
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            //设置公司代码

            IList <QuterModuleSetModel> QuterModuleSetList = new List <QuterModuleSetModel>();

            if (chMMubiao.Checked)
            {
                if (chMRi.Checked)
                {
                    QuterModuleSetModel dchMRi = new QuterModuleSetModel();
                    dchMRi.CompanyCD = userInfo.CompanyCD;
                    dchMRi.Sign      = "2";
                    dchMRi.ModuleID  = "1001";
                    dchMRi.QuarterNo = model.QuarterNo;
                    dchMRi.DeptID    = model.DeptID;
                    dchMRi.TypeID    = "1";

                    QuterModuleSetList.Add(dchMRi);
                }
                if (this.chMZhou.Checked)
                {
                    QuterModuleSetModel dMZhou = new QuterModuleSetModel();
                    dMZhou.CompanyCD = userInfo.CompanyCD;
                    dMZhou.Sign      = "2";
                    dMZhou.ModuleID  = "1001";
                    dMZhou.QuarterNo = model.QuarterNo;
                    dMZhou.DeptID    = model.DeptID;
                    dMZhou.TypeID    = "2";

                    QuterModuleSetList.Add(dMZhou);
                }
                if (this.chMYue.Checked)
                {
                    QuterModuleSetModel dMYue = new QuterModuleSetModel();
                    dMYue.CompanyCD = userInfo.CompanyCD;
                    dMYue.Sign      = "2";
                    dMYue.ModuleID  = "1001";
                    dMYue.QuarterNo = model.QuarterNo;
                    dMYue.DeptID    = model.DeptID;
                    dMYue.TypeID    = "3";

                    QuterModuleSetList.Add(dMYue);
                }
                if (this.chMJi.Checked)
                {
                    QuterModuleSetModel dMJi = new QuterModuleSetModel();
                    dMJi.CompanyCD = userInfo.CompanyCD;
                    dMJi.Sign      = "2";
                    dMJi.ModuleID  = "1001";
                    dMJi.QuarterNo = model.QuarterNo;
                    dMJi.DeptID    = model.DeptID;
                    dMJi.TypeID    = "4";

                    QuterModuleSetList.Add(dMJi);
                }
                if (this.chMNian.Checked)
                {
                    QuterModuleSetModel dMNian = new QuterModuleSetModel();
                    dMNian.CompanyCD = userInfo.CompanyCD;
                    dMNian.Sign      = "2";
                    dMNian.ModuleID  = "1001";
                    dMNian.QuarterNo = model.QuarterNo;
                    dMNian.DeptID    = model.DeptID;
                    dMNian.TypeID    = "5";

                    QuterModuleSetList.Add(dMNian);
                }
            }



            if (chRRenWu.Checked)
            {
                if (chRGEren.Checked)
                {
                    QuterModuleSetModel dchGEren = new QuterModuleSetModel();
                    dchGEren.CompanyCD = userInfo.CompanyCD;
                    dchGEren.Sign      = "2";
                    dchGEren.ModuleID  = "1011";
                    dchGEren.QuarterNo = model.QuarterNo;
                    dchGEren.DeptID    = model.DeptID;
                    dchGEren.TypeID    = "1";

                    QuterModuleSetList.Add(dchGEren);
                }
                if (this.chRZhipai.Checked)
                {
                    QuterModuleSetModel dMZhipai = new QuterModuleSetModel();
                    dMZhipai.CompanyCD = userInfo.CompanyCD;
                    dMZhipai.Sign      = "2";
                    dMZhipai.ModuleID  = "1011";
                    dMZhipai.QuarterNo = model.QuarterNo;
                    dMZhipai.DeptID    = model.DeptID;
                    dMZhipai.TypeID    = "2";

                    QuterModuleSetList.Add(dMZhipai);
                }
            }



            QuterModuleSetModel ModelchGgongzuo = new QuterModuleSetModel();
            ModelchGgongzuo.CompanyCD = userInfo.CompanyCD;
            ModelchGgongzuo.Sign      = "2";
            if (chGgongzuo.Checked)
            {
                ModelchGgongzuo.ModuleID  = "1021";
                ModelchGgongzuo.QuarterNo = model.QuarterNo;
                ModelchGgongzuo.DeptID    = model.DeptID;
            }
            QuterModuleSetList.Add(ModelchGgongzuo);



            QuterModuleSetModel ModelchCricheng = new QuterModuleSetModel();
            ModelchCricheng.CompanyCD = userInfo.CompanyCD;
            ModelchCricheng.Sign      = "2";
            if (chCricheng.Checked)
            {
                ModelchCricheng.ModuleID  = "10411";
                ModelchCricheng.QuarterNo = model.QuarterNo;
                ModelchCricheng.DeptID    = model.DeptID;
            }
            QuterModuleSetList.Add(ModelchCricheng);



            if (DeptQuarterBus.SaveQuarterSet(QuterModuleSetList))
            {
                lblErrorMes.Visible     = true;
                lblErrorMes.Text        = "保存成功!";
                hidEditFlag.Value       = ConstUtil.EDIT_FLAG_UPDATE;
                txtDisplayCode.Value    = model.QuarterNo;
                txtDisplayCode.Disabled = true;
                hidDeptInfo.Value       = model.DeptID;
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), " ", " <script> SaveAfter(); </script> ");
            }
            else
            {
                lblErrorMes.Visible = true;
                lblErrorMes.Text    = "保存失败!";
            }
        }
        //保存未成功时
        else
        {
            lblErrorMes.Visible = true;
            lblErrorMes.Text    = "保存失败!";
        }
    }