Exemplo n.º 1
0
 /// <summary>
 /// 添加部门(确定按钮)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ImageButton1_Click(object sender, EventArgs e)
 {
     try
     {
         if (DropDownList1.Text != "0")
         {
             if (TextBox1.Text.Trim() != "")
             {
                 if (TextBox6.Text.Trim() != "")
                 {
                     if (TextBox6.Text.Trim() == TextBox7.Text.Trim())
                     {
                         DataSet dss = op.GetList(" name like '" + TextBox1.Text + "' and pwd like '" + FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox6.Text.Trim(), "MD5") + "'");
                         if (dss.Tables[0].Rows.Count > 0)
                         {
                             ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('账号密码以存在!');</script>");
                             TextBox1.Text = "";
                             TextBox6.Text = "";
                             TextBox7.Text = "";
                             ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
                         }
                         else
                         {
                             Maticsoft.Model.Operator czy = new Model.Operator();
                             czy.StaffmemberID = Convert.ToInt32(DropDownList1.Text);
                             czy.name          = TextBox1.Text;
                             czy.pwd           = FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox6.Text.Trim(), "MD5");
                             czy.Beizhu        = TextBox2.Text;
                             czy.BranchID      = 1;
                             int a = op.Add(czy);
                             if (a > 0)
                             {
                                 DataSet er = op.GetList(" name like '" + TextBox1.Text + "' and pwd like '" + FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox6.Text.Trim(), "MD5") + "' and StaffmemberID like '" + DropDownList1.Text + "' and BranchID like '1'");
                                 Model.Permissionstab per = new Model.Permissionstab();
                                 per.Operatorid = Convert.ToInt32(er.Tables[0].Rows[0]["id"]);
                                 per.Look       = 0;
                                 per.Audit      = 0;
                                 int aa = pe.Add(per);
                                 if (aa > 0)
                                 {
                                     ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('添加成功!');</script>");
                                     bind(sql);
                                 }
                                 else
                                 {
                                     ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('权限添加失败!');</script>");
                                     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
                                 }
                             }
                             else
                             {
                                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('添加失败!');</script>");
                                 bind(sql);
                             }
                         }
                     }
                     else
                     {
                         ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('2次输入的密码不一致请重新输入!');</script>");
                         TextBox6.Text = "";
                         TextBox7.Text = "";
                         ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
                     }
                 }
                 else
                 {
                     ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('密码不能为空!');</script>");
                     ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
                 }
             }
             else
             {
                 ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('账号不能为空!');</script>");
                 ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
             }
         }
         else
         {
             ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('没选职员!');</script>");
             ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>");
         }
     }
     catch (Exception ee)
     {
         //Response.Write("<script>alert('确定异常 " + ee.Message + "')</script>");
         ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('确定异常 " + ee.Message + "');</script>");
     }
 }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtname.Text.Trim().Length == 0)
            {
                strErr += "name不能为空!\\n";
            }
            if (this.txtpwd.Text.Trim().Length == 0)
            {
                strErr += "pwd不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtBranchID.Text))
            {
                strErr += "BranchID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtdepartmentID.Text))
            {
                strErr += "departmentID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtStaffmemberID.Text))
            {
                strErr += "StaffmemberID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtJurisdictionID.Text))
            {
                strErr += "JurisdictionID格式错误!\\n";
            }
            if (this.txtBeizhu.Text.Trim().Length == 0)
            {
                strErr += "Beizhu不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtBY1.Text))
            {
                strErr += "BY1格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtBY2.Text))
            {
                strErr += "BY2格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtBY3.Text))
            {
                strErr += "BY3格式错误!\\n";
            }
            if (this.txtBY4.Text.Trim().Length == 0)
            {
                strErr += "BY4不能为空!\\n";
            }
            if (this.txtBY5.Text.Trim().Length == 0)
            {
                strErr += "BY5不能为空!\\n";
            }
            if (this.txtBY6.Text.Trim().Length == 0)
            {
                strErr += "BY6不能为空!\\n";
            }
            if (this.txtBY7.Text.Trim().Length == 0)
            {
                strErr += "BY7不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string  name           = this.txtname.Text;
            string  pwd            = this.txtpwd.Text;
            int     BranchID       = int.Parse(this.txtBranchID.Text);
            int     departmentID   = int.Parse(this.txtdepartmentID.Text);
            int     StaffmemberID  = int.Parse(this.txtStaffmemberID.Text);
            int     JurisdictionID = int.Parse(this.txtJurisdictionID.Text);
            string  Beizhu         = this.txtBeizhu.Text;
            decimal BY1            = decimal.Parse(this.txtBY1.Text);
            decimal BY2            = decimal.Parse(this.txtBY2.Text);
            decimal BY3            = decimal.Parse(this.txtBY3.Text);
            string  BY4            = this.txtBY4.Text;
            string  BY5            = this.txtBY5.Text;
            string  BY6            = this.txtBY6.Text;
            string  BY7            = this.txtBY7.Text;

            Maticsoft.Model.Operator model = new Maticsoft.Model.Operator();
            model.name           = name;
            model.pwd            = pwd;
            model.BranchID       = BranchID;
            model.departmentID   = departmentID;
            model.StaffmemberID  = StaffmemberID;
            model.JurisdictionID = JurisdictionID;
            model.Beizhu         = Beizhu;
            model.BY1            = BY1;
            model.BY2            = BY2;
            model.BY3            = BY3;
            model.BY4            = BY4;
            model.BY5            = BY5;
            model.BY6            = BY6;
            model.BY7            = BY7;

            Maticsoft.BLL.Operator bll = new Maticsoft.BLL.Operator();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }