示例#1
0
 public List<Depot> GetDepotByCompanyId(int compId)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@company_id", compId)
     };
     List<Depot> result = new List<Depot>();
     string sql = "SELECT id, name, department_id, contact_person, phone, fax, address, status, company_id FROM depots WHERE company_id =        @company_id AND is_delete = 0";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             Depot depot = new Depot();
             depot.Id = dr.GetInt32(0);
             depot.Name = dr.GetString(1);
             Department depart = new DepartmentDAL().GetDepartmentById(dr.GetInt32(2));
             depot.Department = depart;
             depot.ContactPerson = dr.GetString(3);
             depot.Phone = dr.GetString(4);
             depot.Fax = dr.GetString(5);
             depot.Address = dr.GetString(6);
             depot.Status = dr.GetBoolean(7);
             depot.CompanyId = dr.GetInt32(8);
             result.Add(depot);
         }
     }
     return result;
 }
示例#2
0
 public List<Depot> GetDepot()
 {
     List<Depot> result = new List<Depot>();
     string sql = "SELECT id, name, department_id, contact_person, phone, fax, address, status, company_id FROM depots WHERE is_delete = 0";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, null))
     {
         while (dr.Read())
         {
             Depot depot = new Depot();
             depot.Id = dr.GetInt32(0);
             depot.Name = dr.GetString(1);
             Department depart = new DepartmentDAL().GetDepartmentById(dr.GetInt32(2));
             depot.Department = depart;
             depot.ContactPerson = dr.GetString(3);
             depot.Phone = dr.GetString(4);
             depot.Fax = dr.GetString(5);
             depot.Address = dr.GetString(6);
             depot.Status = dr.GetBoolean(7);
             depot.CompanyId = dr.GetInt32(8);
             result.Add(depot);
         }
     }
     return result;
 }
示例#3
0
 public Depot GetDepotByName(string name)
 {
     Depot depot = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputNVarcharParameter("@name", 50, name)
     };
     string sql = "SELECT id, name, department_id, contact_person, phone, fax, address, status, company_id FROM depots WHERE name = @name AND is_delete = 0";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             depot = new Depot();
             depot.Id = dr.GetInt32(0);
             depot.Name = dr.GetString(1);
             Department depart = new DepartmentDAL().GetDepartmentById(dr.GetInt32(2));
             depot.Department = depart;
             depot.ContactPerson = dr.GetString(3);
             depot.Phone = dr.GetString(4);
             depot.Fax = dr.GetString(5);
             depot.Address = dr.GetString(6);
             depot.Status = dr.GetBoolean(7);
             depot.CompanyId = dr.GetInt32(8);
         }
     }
     return depot;
 }