Exemplo n.º 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        PRoleData model = new PRoleData();
        PRoleBB roleBB = new PRoleBB();
        if (this.roleName.Text == "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"��λ���Ʊ�����д!\");", true);
        }
        else
        {
            try
            {
                if (this.State == "1")
                {
                    this.SetModel(ref model);
                    //model.isrtEmpId = this.currentUser.empId;
                    //model.isrtDt = DateTime.Now.ToString();
                    this.IdValue = roleBB.AddRecord(model);
                }
                else if (this.State == "2")
                {
                    model = roleBB.GetModel(this.IdValue);
                    this.SetModel(ref model);
                    if (model.isSys)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"����λΪϵͳ��λ�����޷��޸ġ�\");", true);
                        return;
                    }
                    roleBB.ModifyRecord(model);
                }
            }
            catch (Exception ex)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
                return;
            }
            finally
            {
                roleBB.Dispose();
            }

            Response.Redirect("PRoleList.aspx?itemNo=" + this.itemNo + "&pTypeNo=main", false);
        }
    }