protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (checkName() && Page.IsValid)
            {
                Branch _Branch = new Branch();
                _Branch.ID = branchID;
                _Branch.Name = txtBranchName.Text;
                _Branch.Email = txtBranchEmail.Text;
                _Branch.Phone = txtPhone.Text;
                _Branch.Address = txtAddress.Text;
                _Branch.Description = txtDescription.Text;

                bool result = BranchBLL.UpdateBranch(_Branch);
                if (result)
                {
                    lblStatusUpdate.Text = "Update branch Successful!";
                    Response.AddHeader("REFRESH", "2;URL=BranchManagement.aspx");
                }
                else
                {
                    lblStatusUpdate.Text = "Can not update branch !";
                    return;
                }
            }
        }
 public void LoadBranch()
 {
     branch = new Branch();
     branch = BranchBLL.GetBranchByID(branchID)[0];
     txtBranchName.Text = branch.Name;
     txtBranchEmail.Text = branch.Email;
     txtPhone.Text = branch.Phone;
     txtAddress.Text = branch.Address;
     txtDescription.Text = branch.Description;
 }
Beispiel #3
0
 public Branch BranchIDatareader(IDataReader dr)
 {
     Branch obj = new Branch();
     obj.ID = (dr["ID"] is DBNull) ? string.Empty : dr["ID"].ToString();
     obj.Name = (dr["Name"] is DBNull) ? string.Empty : dr["Name"].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.Description = (dr["Description"] is DBNull) ? string.Empty : dr["Description"].ToString();
     return obj;
 }
Beispiel #4
0
 public List<Branch> GetAllBranch()
 {
     List<Branch> list = new List<Branch>();
     using (SqlCommand cmd = GetCommand("getAllBranch", CommandType.StoredProcedure))
     {
         Branch branch = new Branch();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(branch.BranchIDatareader(dr));
                 }
             }
         }
         branch = null;
     }
     return list;
 }
Beispiel #5
0
 public List<Branch> GetBranchByID(string id)
 {
     List<Branch> list = new List<Branch>();
     using (SqlCommand cmd = GetCommand("getBranchByID", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@ID", Convert.ToInt32(id));
         Branch branch = new Branch();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(branch.BranchIDatareader(dr));
                 }
             }
         }
         branch = null;
     }
     return list;
 }
Beispiel #6
0
 public bool UpdateBranch(Branch branch)
 {
     using (SqlCommand cmd = GetCommand("updateBranch", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@ID", branch.ID);
         AddParameter(cmd, "@Name", branch.Name);
         AddParameter(cmd, "@Email", branch.Email);
         AddParameter(cmd, "@Phone", branch.Phone);
         AddParameter(cmd, "@Address", branch.Address);
         AddParameter(cmd, "@Description", branch.Description);
         int result = ExeNonQuery(cmd);
         return result > 0;
     }
 }
Beispiel #7
0
 public List<Branch> SearchBranchByName(string name)
 {
     List<Branch> list = new List<Branch>();
     using (SqlCommand cmd = GetCommand("searchBranchByName", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@Name", name);
         Branch branch = new Branch();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(branch.BranchIDatareader(dr));
                 }
             }
         }
         branch = null;
     }
     return list;
 }
Beispiel #8
0
 public static bool UpdateBranch(Branch branch)
 {
     return db.UpdateBranch(branch);
 }
Beispiel #9
0
 public static bool InsertBranch(Branch branch)
 {
     return db.InsertBranch(branch);
 }