Exemple #1
0
        /*
         * protected void RegisterUser_CreatedUser(object sender, EventArgs e)
         * {
         *  FormsAuthentication.SetAuthCookie(this.txtUsrName.Text.ToString().Trim(), false);
         *
         *  string continueUrl = Request.QueryString["ReturnUrl"];
         *  if (String.IsNullOrEmpty(continueUrl))
         *  {
         *      continueUrl = "~/";
         *  }
         *  Response.Redirect(continueUrl);
         * }
         */
        protected void btnReg_Click(object sender, EventArgs e)
        {
            if (inputCheck())
            {
                string usrName      = txtUsrName.Text.ToString().Trim();
                string realName     = txtRealName.Text.ToString().Trim();
                string usrMobile    = txtMobile.Text.ToString().Trim();
                string usrEmail     = txtEmail.Text.ToString().Trim();
                string departmentId = ddlDepart.SelectedValue.ToString().Trim();
                string titleId      = ddlTitle.SelectedValue.ToString().Trim();
                //int sc = int.Parse(txtContact.Text.ToString().Trim());

                #region dataset
                DataSet dataSet = new DataSet();
                DataRow userRow = null;

                DataColumn colName      = new DataColumn("realName", System.Type.GetType("System.String"));
                DataColumn colUsrName   = new DataColumn("usrName", System.Type.GetType("System.String"));
                DataColumn colUsrMobile = new DataColumn("usrMobile", System.Type.GetType("System.String"));
                DataColumn colUsrEmail  = new DataColumn("usrEmail", System.Type.GetType("System.String"));
                DataColumn colDepartId  = new DataColumn("departmentId", System.Type.GetType("System.String"));
                DataColumn colTitleId   = new DataColumn("titleId", System.Type.GetType("System.String"));

                DataTable userTable = new DataTable("addTable");

                userTable.Columns.Add(colName);
                userTable.Columns.Add(colUsrName);
                userTable.Columns.Add(colUsrMobile);
                userTable.Columns.Add(colUsrEmail);
                userTable.Columns.Add(colDepartId);
                userTable.Columns.Add(colTitleId);

                userRow                 = userTable.NewRow();
                userRow["realName"]     = realName;
                userRow["usrName"]      = usrName;
                userRow["usrMobile"]    = usrMobile;
                userRow["usrEmail"]     = usrEmail;
                userRow["departmentId"] = departmentId;
                userRow["titleId"]      = titleId;
                userTable.Rows.Add(userRow);

                dataSet.Tables.Add(userTable);
                #endregion

                UserProcess up = new UserProcess(dataSet);

                string error = up.Add_includeError();

                if (string.IsNullOrEmpty(error))
                {
                    Response.Redirect("~/Main/usrManagerment/usrInfoManagerment.aspx");
                }
                else
                {
                    lblName.Text = error;
                }
            }
        }