protected void btnChange_Click(object sender, EventArgs e)
        {
            TblBranchUser obj = new TblBranchUser(TblBranchUser.Columns.Contact, txtContact.Text);

            if (!String.IsNullOrEmpty(obj.Contact))
            {
                if (obj.VerificationCode == txtCode.Text)
                {
                    obj.IsNew    = false;
                    obj.Password = txtNewPassword.Text;
                    obj.Save();
                    divReset.Visible          = false;
                    divPasswordUpdate.Visible = false;
                    divLogin.Visible          = true;
                    lblmsg.ForeColor          = Color.Green;
                    lblmsg.Text = "Password has been updated!";
                }
                else
                {
                    lblmsg.ForeColor = Color.Red;
                    lblmsg.Text      = "Invalid Code.!";
                }
            }
            else
            {
                lblmsg.ForeColor = Color.Red;
                lblmsg.Text      = "Invalid account contact no.!";
            }
        }
Beispiel #2
0
        private void loadData(string BranchID)
        {
            hfUserID.Value = string.Empty;
            TblBranchUser obj = new TblBranchUser(TblBranchUser.Columns.BranchID, BranchID);

            if (obj.UserID != 0)
            {
                hfUserID.Value   = obj.UserID.ToString();
                txtUserName.Text = obj.UserName;
                txtContact.Text  = obj.Contact;
                txtEmail.Text    = obj.Email;
                txtAddress.Text  = obj.Address;
                //   reqFile.Enabled = false;
            }
            else
            {
                //foreach (Control ctrl in this.Controls)
                //{
                //    if (ctrl is TextBox)
                //        ((TextBox)ctrl).Text = string.Empty;
                //}
                txtUserName.Text = string.Empty;
                txtContact.Text  = string.Empty;
                txtEmail.Text    = string.Empty;
                txtAddress.Text  = string.Empty;
            }
        }
        protected void btnChangePassword_Click(object sender, EventArgs e)
        {
            TblBranchUser obj = new TblBranchUser(Session["BranchUserID"]);

            obj.IsNew    = false;
            obj.IsFirst  = false;
            obj.Password = txtfNewPassword.Text;
            obj.Save();
            divLogin.Visible      = true;
            divFirstLogin.Visible = false;
        }
Beispiel #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (helper.ExecutePlainQuery("select * from tbl_BranchUser where Email='" + txtEmail.Text + "'").Rows.Count > 0 && String.IsNullOrEmpty(Convert.ToString(hfUserID.Value)))
                {
                    lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, txtEmail.Text + " already exists!", "alert alert-danger alert-icon alert-dismissible", icon, "icon mdi mdi-close-circle-o");
                }
                else
                {
                    string        msg = "User detail has been added!";
                    TblBranchUser obj = new TblBranchUser();
                    obj.IsNew = true;

                    if (!String.IsNullOrEmpty(Convert.ToString(hfUserID.Value)))
                    {
                        obj.IsNew = false;
                        obj       = new TblBranchUser(hfUserID.Value);
                        msg       = "User detail has been updated!";
                    }

                    obj.BranchID = Convert.ToInt16(ddlBranches.SelectedValue);
                    obj.UserName = txtUserName.Text;
                    obj.Contact  = txtContact.Text;
                    obj.Email    = txtEmail.Text;
                    obj.Image    = "N/A";
                    obj.Address  = txtAddress.Text;
                    obj.IsActive = true;

                    if (obj.IsNew == true)
                    {
                        obj.IsFirst  = true;
                        obj.Password = helper.generateRandomCode(5);
                        SendSms.SendMessage(txtContact.Text, "Your account has been registered! Your password is " + obj.Password);
                        SendEmail.Mail(txtEmail.Text, "Password", "Your account has been registered! Your password is " + obj.Password);
                    }

                    obj.Save();
                    lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, msg, "alert alert-success alert-icon alert-dismissible", icon, "icon mdi mdi-check");
                    helper.ClearInputs(Page.Controls);
                    hfUserID.Value = string.Empty;
                    //   reqFile.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, ex.ToString(), "alert alert-danger alert-icon alert-dismissible", icon, "icon mdi mdi-close-circle-o");
            }
        }
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         LinkButton    userID = (LinkButton)sender;
         TblBranchUser obj    = new TblBranchUser(userID.CommandArgument);
         obj.IsActive = false;
         obj.IsNew    = false;
         obj.Save();
         lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, "User detail has been deleted!", "alert alert-danger alert-icon alert-dismissible", icon, "icon mdi mdi-check");
         rptUsers.DataBind();
     }
     catch (Exception ex) {
     }
 }
        protected void btnSignIN_Click(object sender, EventArgs e)
        {
            DataTable dt = TblBranchUser.BranchUserLogin(txtBranchName.Text, txtBranchPassword.Text);

            if (dt.Rows.Count > 0)
            {
                if (Convert.ToBoolean(dt.Rows[0]["ActiveUser"]) == false)
                {
                    lblmsg.ForeColor = Color.Red;
                    lblmsg.Text      = "Account is deactivated! <br> Please contact with administration";
                }
                else
                {
                    Session.Clear();
                    Session["BranchUserID"] = dt.Rows[0]["UserID"].ToString();
                    if (Convert.ToBoolean(dt.Rows[0]["isFirst"]) == true)
                    {
                        divLogin.Visible      = false;
                        divFirstLogin.Visible = true;
                    }
                    else
                    {
                        if (chkremember.Checked)
                        {
                            Response.Cookies["BranchUserName"].Value       = txtBranchName.Text;
                            Response.Cookies["BracnhUserPassword"].Value   = txtBranchPassword.Text;
                            Response.Cookies["BranchUserName"].Expires     = DateTime.Now.AddDays(30);
                            Response.Cookies["BracnhUserPassword"].Expires = DateTime.Now.AddDays(30);
                        }
                        Session["BranchID"]        = dt.Rows[0]["BranchID"].ToString();
                        Session["BranchUserEmail"] = dt.Rows[0]["Email"].ToString();
                        Session["BranchUserName"]  = dt.Rows[0]["UserName"].ToString();
                        Session["BranchName"]      = dt.Rows[0]["BranchName"].ToString();
                        Response.Redirect("Index.aspx");
                    }
                }
            }
            else
            {
                lblmsg.ForeColor = Color.Red;
                lblmsg.Text      = "Invalid UserName or Password!";
            }
        }
        protected void btnSendCode_Click(object sender, EventArgs e)
        {
            TblBranchUser obj = new TblBranchUser(TblBranchUser.Columns.Contact, txtContact.Text);

            if (!String.IsNullOrEmpty(obj.Contact))
            {
                obj.IsNew            = false;
                obj.VerificationCode = helper.generateRandomCode(5);
                SendSms.SendMessage(txtContact.Text, "Your password reset code is " + obj.VerificationCode);
                obj.Save();
                divReset.Visible          = false;
                divPasswordUpdate.Visible = true;
            }
            else
            {
                lblmsg.ForeColor = Color.Red;
                lblmsg.Text      = "Invalid account contact no.!";
            }
        }