示例#1
0
        protected void btnUserCreate_click(object sender, EventArgs e)
        {
            try
            {
                if (!checkDuplicateUser())
                {

                    UserBLL aUser = new UserBLL();
                    LoginBll login = new LoginBll();
                    aUser.UserId = txtbxUserName.Text.Trim();
                    aUser.FirstName = txtbxUserName.Text.Trim();
                    aUser.LastName = "";
                    aUser.PassportNo = "";
                    aUser.Address = "";
                    aUser.Country = "";
                    aUser.House = "";
                    aUser.Street = "";
                    aUser.Area = "";
                    aUser.MobileNo = txtbxmobile.Text.Trim();
                    aUser.Email = txtbxemail.Text.Trim();
                    aUser.EmrName = "";
                    aUser.EmrRelation = "";
                    aUser.EmrAddress = "";
                    aUser.EmrMobile = "";
                    aUser.EmeEmail = "";
                    aUser.EmeCountry = "";
                    aUser.ActualPass = "";
                    aUser.UserPin = passwordTextBox.Text;
                    aUser.IsActive = "No";
                    aUser.Isvarified = "Yes";
                    aUser.Createdby = "";
                    aUser.UserGroupId = drpdownGroup.SelectedValue;
                    aUser.Certificate = "";
                    aUser.Password = LumexLibraryManager.EncodeIntoMd5Hash("LTSsL[" + passwordTextBox.Text + "]0");
                    aUser.ActualPass = passwordTextBox.Text;
                    string IsUpload = photoUploadfn(aUser.Email);

                    if (IsUpload == "")
                    {
                        msgbox.Attributes.Add("Class", "alert alert-warning");
                        msgTitleLabel.Text = "Error!!!!";
                        msgDetailLabel.Text = "Pleace Check File Extention or File size.You can only upload Image and size less than 128Kb";
                        msgbox.Visible = true;
                        string message = " <span class='actionTopic'>" + " Pleace Check File Extention or File size.You can only upload Image and size less than 128Kb</span>.";
                        MyAlertBox("var callbackOk = function () { window.location = \"/setting/user/create.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                    }
                    else
                    {

                        aUser.PerPhoto = IsUpload;
                        bool status = aUser.SaveUserInfo();
                        if (status)
                        {

                            //bool st = SendConformationEmail(userbll);
                            //if (st)
                            //{

                            string message = " <span class='actionTopic'>" + "User Create Successfully</span>.";
                            MyAlertBox("var callbackOk = function () { window.location = \"/setting/user/create.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                        }
                        //else
                        //{
                        //    string message = " <span class='actionTopic'>" + "User Create Successfully.But Not Send Please Contact Your Admistration.</span>.";
                        //    MyAlertBox("var callbackOk = function () { window.location = \"/setting/user/list.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                        //}
                        //  }

                        //    }

                        //}

                    }
                }
            }
            catch (Exception ex)
            {

                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");

            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                UserBLL aUser = new UserBLL();
                if (txtbxUserName.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "User Name field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxUserName.Focus();
                }
                else if (txtbxFirstName.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "First Name field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxFirstName.Focus();
                }
                else if (txtbxLastName.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Last Name field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxLastName.Focus();
                }
                else if (txtbxAddress.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Address field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxAddress.Focus();
                }
                else if (txtbxHouse.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "House No field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxHouse.Focus();
                }
                else if (txtbxStreet.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Street field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxStreet.Focus();
                }
                else if (txtbxCell.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Cell Number field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxCell.Focus();
                }
                else if (txtbxCellConfrm.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Cell Confirm field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxCellConfrm.Focus();
                }
                else if (txtbxEmail.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Email field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxEmail.Focus();
                }
                else if (txtbxPin.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Pin field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxPin.Focus();
                }
                else if (txtbxReferId.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Reffer ID field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxReferId.Focus();
                }
                else if (txtbxPlacementId.Text == ""||txtbxPlacementId.Text==txtbxUserName.Text)
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Placement ID field is required. or Not valid.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxPlacementId.Text = "";
                    txtbxPlacementId.Focus();
                }
                else if (ddlPosition.SelectedItem.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Join Position field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    ddlPosition.Focus();
                }

                else
                {
                    if (!aUser.CheckDuplicateUser(txtbxUserName.Text) && hdnvalidplace.Value == "0")
                    {

                        LoginBll login = new LoginBll();
                        aUser.UserId = txtbxUserName.Text.Trim();
                        aUser.FirstName = txtbxFirstName.Text.Trim();
                        aUser.LastName = txtbxLastName.Text.Trim();
                        aUser.PassportNo = txtbxPassportNo.Text.Trim();
                        aUser.Address = txtbxAddress.Text.Trim();
                        aUser.Country = ddlCountry.SelectedValue;
                        aUser.House = txtbxHouse.Text.Trim();
                        aUser.Street = txtbxStreet.Text.Trim();
                        aUser.Area = txtbxArea.Text.Trim();
                        aUser.MobileNo = txtbxCell.Text.Trim();
                        aUser.Email = txtbxEmail.Text.Trim();
                        aUser.EmrName = txtcontactPerson.Text.Trim();
                        aUser.EmrRelation = ddlContactRelation.SelectedValue;
                        aUser.EmrAddress = txtbxContactAddress.Text.Trim();
                        aUser.EmrMobile = txtbxContactMobile.Text.Trim();
                        aUser.EmeEmail = txtContactEmail.Text.Trim();
                        aUser.EmeCountry = ddlContactCountry.SelectedValue;
                        aUser.UserGroupId = "UG003";
                        aUser.Password =
                            (string)
                                LumexLibraryManager.EncodeIntoMd5Hash("LTSsL[" + txtpxPasswordset.Text.Trim() + "]0");
                        ;
                        aUser.ActualPass = retypePassword.Text.Trim();
                        aUser.UserPin = txtbxPin.Text.Trim();
                        aUser.IsActive = "No";
                        aUser.PerPhoto = "";
                        aUser.Isvarified = "No";
                        aUser.Createdby = "";
                        bool status = aUser.SaveUserInfo();
                        if (status)
                        {

                            if (txtbxPlacementId.Text != "" && ddlPosition.SelectedValue != "" &&
                                txtbxReferId.Text != "")
                            {
                                aUser.InsertIntoGenolgyTree(txtbxPlacementId.Text, ddlPosition.SelectedValue,
                                    txtbxReferId.Text, aUser.UserId);
                            }
                            Random random = new Random();
                            MailContactBLL mailContactBll = new MailContactBLL();
                            aUser.varifycode = random.Next(100000, 999998) + 1;

                            string key = dataEncryptbll.addforvarifycore;
                            string encrypeteduid = dataEncryptbll.EncryptRijndael(
                                aUser.UserId + "#" + aUser.varifycode, key);
                            string url = HttpContext.Current.Request.Url.AbsoluteUri;
                            string[] Partsofurl = url.Split('/');
                            aUser.ActivationUrl =
                                Server.HtmlEncode("http://" + Partsofurl[2] + "/page/varify.aspx/?uid=" + encrypeteduid);
                            string body = PopulateBody(aUser);

                            bool mailSend = mailContactBll.sendemailtocompleteResigtration(aUser, body);
                            aUser = null;
                            ClearTextBox();

                        }
                    }
                    else
                    {
                        string message = " <span class='actionTopic'>" + " Placement Informarion is not correct!!" +
                                         ddlPosition.SelectedItem.Text + " Is not free of the Placement Id</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { window.location = \"/page/registration.aspx\"; }; WarningAlert(\"" +
                            "Process Succeed" + "\", \"" + message + "\", \"\");");
                    }
                }
            }
            catch (Exception)
            {

                throw;
            }
        }