コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                //errNumber = -1;
                try
                {
                    objBusinessClass = new BusinessLayer.BusinessClass();
                    objML_UserName   = new ML_UserName();


                    objML_UserName.UserName  = ML_Common.clean(txtUserName.Text);
                    objML_UserName.FirstName = ML_Common.clean(txtFirstName.Text);
                    objML_UserName.LastName  = ML_Common.clean(txtLastName.Text);
                    objML_UserName.Email     = ML_Common.clean(txtEmail.Text);
                    objML_UserName.Telephone = ML_Common.clean(txtTelephone.Text);
                    objML_UserName.Mobile    = ML_Common.clean(txtMobile.Text);
                    objML_UserName.Password  = ML_Common.clean(txtPassword.Text);


                    objML_UserName.UserTypeId = ML_Common.string2int32(ML_Common.GetDropDownValue(ddlUserType, true));
                    objML_UserName.UserType   = ML_Common.string2string(ML_Common.GetDropDownValue(ddlUserType, false));

                    objML_UserName.ReTryAttempt   = 3;     // ML_Common.string2int32(ML_Common.clean(txtReTryAttempt.Text));
                    objML_UserName.IsLocked       = false; // ML_Common.string2Boolean(ML_Common.clean(txtIsLocked.Text));
                    objML_UserName.LockedDateTime = ML_Common.ToDateTimeSafe(System.DateTime.Now.ToString());
                    objML_UserName.IsActive       = ML_Common.clean(ML_Common.bit2int(true).ToString());
                    objML_UserName.IsArchive      = ML_Common.clean(ML_Common.bit2int(false).ToString());
                    objML_UserName.CreatedDate    = ML_Common.ToDateTimeSafe(System.DateTime.Now.ToString());

                    objML_UserName.ModifiedDate = ML_Common.ToDateTimeSafe(System.DateTime.Now.ToString());


                    if (Session["UserName"] != null && Session["UserNameId"] != null)
                    {
                        objML_UserName.CreatedBy           = ML_Common.clean(Session["UserName"]);
                        objML_UserName.ModifiedBy          = ML_Common.clean(Session["UserName"]);
                        objML_UserName.CreatedByUserNameId = ML_Common.string2int32(ML_Common.clean(Session["UserNameId"]));
                    }


                    int obhReturn = objBusinessClass.AddUserName(objML_UserName);

                    if (obhReturn == 1)
                    {
                        lblMsg.Visible = true;
                        lblMsg.Text    = "Record Saved Successfully";
                        FormFieldsClear();
                    }
                    else if (obhReturn == 2)
                    {
                        lblMsg.Text    = "Record Already Exists!";
                        lblMsg.Visible = true;
                    }
                }
                catch (SqlException sqlExc)
                {
                    SqlException sqlExt = sqlExc;
                    return;
                }
                catch (Exception ex)
                {
                    Exception exx = ex;
                }
            }
        }