protected void btnCreate_Click(object sender, EventArgs e)
        {
            if (checkUserName() && Page.IsValid)
            {
                Account account = new Account();
                account.BranchID = ddlBranches.SelectedValue.ToString();
                account.FullName = txtFullName.Text;
                account.UserName = txtUserName.Text;
                account.Password = Common.Encrypt("123456");
                account.Role = ddlRole.SelectedItem.ToString();
                account.Description = txtDescription.Text;

                bool result = AccountBLL.InsertAccount(account);
                if (result)
                {
                    lblStatusAddNewAccount.Text = "create new Account Successful!";
                    Response.AddHeader("REFRESH", "2;URL=AccountManagement.aspx");
                }
                else
                {
                    lblStatusAddNewAccount.Text = "Can not create new Account !";
                    return;
                }
            }
        }
        protected void btnApplyChange_Click(object sender, EventArgs e)
        {
            if (checkBirthDate() && Page.IsValid)
            {
                Account account = new Account();
                account = AccountBLL.GetAccountByID(Session["EmployeeID"].ToString())[0];
                account.FullName = txtFullName.Text;
                account.BirthDate = txtBirthDate.Text;
                account.Email = txtEmail.Text;
                account.Phone = txtPhone.Text;
                account.Address = txtAddress.Text;
                account.Description = txtDescription.Text;
                if (fuPicture.HasFile)
                {
                    string serverPath = Server.MapPath(".");
                    string url = serverPath + @"\imageEmployees\" + fuPicture.FileName;
                    fuPicture.SaveAs(url);

                    account.Picture = "~/Employee/imageEmployees/" + fuPicture.FileName;
                }

                bool result = AccountBLL.UpdateAccount(account);
                if (result)
                {
                    lblStatusUpdate.Text = "Update Successfull!";
                    Response.Redirect("HomeEmployee.aspx");
                }
                else
                {
                    lblStatusUpdate.Text = "Can not Update Profile!";
                }
            }
        }
Ejemplo n.º 3
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     if (AccountBLL.CheckLoginAccount(txtUserName.Text, Common.Encrypt(txtPassword.Text)) == null)
     {
         lblStatusLogin.Text = "User Name or Password wrong!";
         txtUserName.Focus();
         return;
     }
     Account account = new Account();
     account = AccountBLL.CheckLoginAccount(txtUserName.Text, Common.Encrypt(txtPassword.Text))[0];
     if (!account.Active.Equals("True"))
     {
         lblStatusLogin.Text = "Your account is deactivated!";
         txtUserName.Focus();
         return;
     }
     if (account.Role.Equals("Administrator"))
     {
         Session["AccountID"] = account.ID;
         Session["UserName"] = account.UserName;
         Response.Redirect("HomeAdmin.aspx");
     }
     else
     {
         Session["EmployeeID"] = account.ID;
         Session["UserName"] = account.UserName;
         Response.Redirect("~/Employee/HomeEmployee.aspx");
     }
 }
 private void LoadAccount()
 {
     Account account = new Account();
     account = AccountBLL.GetAccountByID(Session["EmployeeID"].ToString())[0];
     txtUserName.Text = account.UserName;
     lblCheckOldPassword.Text = "";
 }
 protected void lbtnDeactivate_Command(object sender, CommandEventArgs e)
 {
     Account account = new Account();
     account = AccountBLL.GetAccountByID(e.CommandArgument.ToString())[0];
     account.Active = (account.Active.Equals("True")) ? "0" : "1";
     AccountBLL.UpdateAccount(account);
     LoadAccounts();
 }
Ejemplo n.º 6
0
 private void LoadData()
 {
     Account account = new Account();
     account = AccountBLL.GetAccountByID(Session["EmployeeID"].ToString())[0];
     lblFullName.Text = account.FullName;
     lblBranchName.Text = BranchBLL.GetBranchByID(account.BranchID)[0].Name;
     lblTotalOrder.Text = OrderBLL.GetAllOrder().Count.ToString();
     lblOrderSending.Text = OrderBLL.GetOrderByStatus("Sending").Count.ToString();
 }
 public void LoadData()
 {
     Account account = new Account();
     account = AccountBLL.GetAccountByID(Session["EmployeeID"].ToString())[0];
     txtFullName.Text = account.FullName;
     imgPicture.ImageUrl = account.Picture;
     //txtBirthDate.Text = Convert.ToDateTime(account.BirthDate).ToShortDateString();
     txtBirthDate.Text = (account.BirthDate == "1/1/1900 12:00:00 AM" || account.BirthDate == "") ? "" : Convert.ToDateTime(account.BirthDate).ToShortDateString();
     txtEmail.Text = account.Email;
     txtPhone.Text = account.Phone;
     txtAddress.Text = account.Address;
     txtDescription.Text = account.Description;
 }
 protected void btnResetPassword_Click(object sender, EventArgs e)
 {
     Account account = new Account();
     account = AccountBLL.GetAccountByID(Request.QueryString["AccountID"].ToString())[0];
     account.Password = Common.Encrypt("123456");
     bool result = AccountBLL.UpdateAccount(account);
     if (result)
     {
         lblStatusUpdateAccount.Text = "Reset Password Successfull!";
     }
     else
     {
         lblStatusUpdateAccount.Text = "Can not Reset Password!";
     }
 }
 public void LoadData()
 {
     Account account = new Account();
     account = AccountBLL.GetAccountByID(Request.QueryString["AccountID"].ToString())[0];
     txtFullName.Text = account.FullName;
     imgPicture.ImageUrl = account.Picture;
     //txtBirthDate.Text = Convert.ToDateTime(account.BirthDate).ToShortDateString();
     //txtBirthDate.Text = (account.BirthDate == "") ? "" : Convert.ToDateTime(account.BirthDate).ToShortDateString();
     txtBirthDate.Text = (account.BirthDate == "1/1/1900 12:00:00 AM" || account.BirthDate == "") ? "" : Convert.ToDateTime(account.BirthDate).ToShortDateString();
     txtEmail.Text = account.Email;
     txtPhone.Text = account.Phone;
     txtAddress.Text = account.Address;
     txtUserName.Text = account.UserName;
     ddlBranches.SelectedValue = account.BranchID;
     ddlRole.SelectedIndex = (account.Role.Equals("Administrator")) ? 1 : 0;
     cbActive.Checked = Convert.ToBoolean(account.Active);
     txtDescription.Text = account.Description;
 }
        protected void btnApplyChange_Click(object sender, EventArgs e)
        {
            Account account = new Account();
            account = AccountBLL.GetAccountByID(Request.QueryString["AccountID"].ToString())[0];
            account.BranchID = ddlBranches.SelectedValue;
            account.Role = ddlRole.SelectedItem.ToString();
            account.Active = (cbActive.Checked) ? "1" : "0";
            account.Description = txtDescription.Text;

            bool result = AccountBLL.UpdateAccount(account);
            if (result)
            {
                lblStatusUpdateAccount.Text = "Update Successfull!";
                Response.Redirect("AccountManagement.aspx");
            }
            else
            {
                lblStatusUpdateAccount.Text = "Can not Update Account!";
            }
        }
 protected void btnApplyChange_Click(object sender, EventArgs e)
 {
     Account account = new Account();
     account = AccountBLL.GetAccountByID(Session["EmployeeID"].ToString())[0];
     if (!Common.Encrypt(txtOldPassword.Text).Equals(account.Password))
     {
         lblCheckOldPassword.Text = "Old Password Invalid!";
         return;
     }
     account.Password = Common.Encrypt(txtNewPassword.Text);
     bool result = AccountBLL.UpdateAccount(account);
     if (result)
     {
         lblStatusChangePassword.Text = "Change Password Successfull!";
         lblCheckOldPassword.Text = "";
     }
     else
     {
         lblStatusChangePassword.Text = "Can not change Password!";
     }
 }
Ejemplo n.º 12
0
 public List<Account> GetAccountByActive(string active)
 {
     List<Account> list = new List<Account>();
     using (SqlCommand cmd = GetCommand("getAccountByActive", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@Active", Convert.ToInt32(active));
         Account account = new Account();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(account.AccountIDatareader(dr));
                 }
             }
         }
         account = null;
     }
     return list;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Check Login Account
 /// </summary>
 /// <param name="userName"></param>
 /// <returns></returns>
 public List<Account> CheckLoginAccount(string userName, string password)
 {
     List<Account> list = new List<Account>();
     using (SqlCommand cmd = GetCommand("checkLoginAccount", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@UserName", userName);
         AddParameter(cmd, "@Password", password);
         Account account = new Account();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(account.AccountIDatareader(dr));
                 }
                 account = null;
                 return list;
             }
             else
                 return null;
         }
     }
 }
Ejemplo n.º 14
0
 public Account AccountIDatareader(IDataReader dr)
 {
     Account obj = new Account();
     obj.ID = (dr["ID"] is DBNull) ? string.Empty : dr["ID"].ToString();
     obj.BranchID = (dr["BranchID"] is DBNull) ? string.Empty : dr["BranchID"].ToString();
     obj.UserName = (dr["UserName"] is DBNull) ? string.Empty : dr["UserName"].ToString();
     obj.Password = (dr["Password"] is DBNull) ? string.Empty : dr["Password"].ToString();
     obj.Role = (dr["Role"] is DBNull) ? string.Empty : dr["Role"].ToString();
     obj.FullName = (dr["FullName"] is DBNull) ? string.Empty : dr["FullName"].ToString();
     obj.Email = (dr["Email"] is DBNull) ? string.Empty : dr["Email"].ToString();
     obj.Phone = (dr["Phone"] is DBNull) ? string.Empty : dr["Phone"].ToString();
     obj.Address = (dr["Address"] is DBNull) ? string.Empty : dr["Address"].ToString();
     obj.BirthDate = (dr["BirthDate"] is DBNull) ? string.Empty : dr["BirthDate"].ToString();
     obj.CreateDate = (dr["CreateDate"] is DBNull) ? string.Empty : dr["CreateDate"].ToString();
     obj.Picture = (dr["Picture"] is DBNull) ? string.Empty : dr["Picture"].ToString();
     obj.Description = (dr["Description"] is DBNull) ? string.Empty : dr["Description"].ToString();
     obj.Active = (dr["Active"] is DBNull) ? string.Empty : dr["Active"].ToString();
     return obj;
 }
Ejemplo n.º 15
0
 public static bool InsertAccount(Account account)
 {
     return db.InsertAccount(account);
 }
Ejemplo n.º 16
0
 public static bool UpdateAccount(Account account)
 {
     return db.UpdateAccount(account);
 }
Ejemplo n.º 17
0
 public List<Account> GetAllAccount()
 {
     List<Account> list = new List<Account>();
     using (SqlCommand cmd = GetCommand("getAllAccount", CommandType.StoredProcedure))
     {
         Account account = new Account();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(account.AccountIDatareader(dr));
                 }
             }
         }
         account = null;
     }
     return list;
 }
Ejemplo n.º 18
0
 public bool UpdateAccount(Account account)
 {
     using (SqlCommand cmd = GetCommand("updateAccount", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@ID", account.ID);
         AddParameter(cmd, "@BranchID", account.BranchID);
         AddParameter(cmd, "@UserName", account.UserName);
         AddParameter(cmd, "@Password", account.Password);
         AddParameter(cmd, "@Role", account.Role);
         AddParameter(cmd, "@FullName", account.FullName);
         AddParameter(cmd, "@Email", account.Email);
         AddParameter(cmd, "@Phone", account.Phone);
         AddParameter(cmd, "@Address", account.Address);
         AddParameter(cmd, "@BirthDate", account.BirthDate);
         AddParameter(cmd, "@Picture", account.Picture);
         AddParameter(cmd, "@Description", account.Description);
         AddParameter(cmd, "@Active", account.Active);
         int result = ExeNonQuery(cmd);
         return result > 0;
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Search Account by UserName
 /// </summary>
 /// <param name="userName"></param>
 /// <returns></returns>
 public List<Account> SearchAccountByUserName(string userName)
 {
     List<Account> list = new List<Account>();
     using (SqlCommand cmd = GetCommand("searchAccountByUserName", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@UserName", userName);
         Account account = new Account();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(account.AccountIDatareader(dr));
                 }
             }
         }
         account = null;
     }
     return list;
 }