Exemplo n.º 1
0
    //提交数据
    protected void Button1_Click(object sender, EventArgs e)
    {
        Hashtable ht = new Hashtable();

        string[] arr1 = new string[] { "num", "sname", "depart", "job", "cell", "email", "leader" };
        for (int i = 0; i < arr1.Length; i++)
        {
            ht.Add(arr1[i], Util.GetControlValue(this.depart.Parent.FindControl(arr1[i])));
        }
        ht.Add("password", "1234");
        ht.Add("login", DateTime.Now.ToString());

        if (ht["sname"].ToString().Trim() == "" || ht["depart"].ToString().Trim() == "")
        {
            Util.alert(this.Page, "错误提示:【用户姓名】和【所在部门】栏目不能为空!");
        }
        else
        {
            U_UserNameBU user1  = new U_UserNameBU();
            bool         result = user1.InsertData(ht);
            user1.Close();
            if (result)
            {
                Response.Redirect("UserMng.aspx", true);
            }
            else
            {
                Util.alert(this.Page, "错误提示:插入数据失败,可能的原因是【" + ht["sname"].ToString() + "】已经存在!");
            }
        }
    }