/// <summary> /// khoi tao gia tri /// </summary> public ThongTinDatHang() { dh = null; Sql = null; conn = null; cmd = null; arr = null; dr = null; dondathang = null; cn = null; }
/// <summary> /// khoi tao gia tri /// </summary> public ThongTinHoaDonNhap() { dh = null; Sql = null; conn = null; cmd = null; arr = null; dr = null; hoadonnhap = null; cn = null; }
/// <summary> /// vuong hung =================lay bang DonDatHang================ /// </summary> /// <returns></returns> public Entities.ThongTinDatHang[] KiemKeHangHoa(Entities.TruyenGiaTri giatri) { Entities.ThongTinDatHang[] arrC = null; try { dh = new Constants.ThongTinDatHang(); Sql = new Constants.Sql(); string sql = Sql.sp_LayBang_HangHoa; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaHangHoa", SqlDbType.VarChar, 50).Value = giatri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { dondathang = new Entities.ThongTinDatHang(); dondathang.MaHangHoa = dr[0].ToString(); dondathang.TenHangHoa = dr[1].ToString(); dondathang.GiaNhap = dr[2].ToString(); dondathang.Tonkho = dr[3].ToString(); dondathang.Giabanbuon = dr[4].ToString(); dondathang.Giabanle = dr[5].ToString(); dondathang.Giatrigiatang = dr[6].ToString(); arr.Add(dondathang); } int n = arr.Count; if (n == 0) { arrC= null; } arrC = new Entities.ThongTinDatHang[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ThongTinDatHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); arrC = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return arrC; }
/// <summary> /// vuong hung =================lay bang hoa don nhap================ /// </summary> /// <returns></returns> public Entities.ThongTinDatHang[] sp_LayBang_HoaDonNhap(Entities.ThongTinDatHang lay) { Entities.ThongTinDatHang[] arrC = null; try { dh = new Constants.ThongTinDatHang(); Sql = new Constants.Sql(); string sql = "exec sp_LayBang_ThongTinHoaDonnhap @MaNhaCungCap"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaNhaCungCap", SqlDbType.VarChar, 20).Value = lay.MaHangHoa; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { hoadonnhap = new Entities.ThongTinDatHang(); hoadonnhap.MaHangHoa = dr[0].ToString().ToUpper(); hoadonnhap.TenHangHoa = dr[1].ToString(); hoadonnhap.GiaNhap = dr[2].ToString(); arr.Add(hoadonnhap); } int n = arr.Count; if (n == 0) { return null; } arrC = new Entities.ThongTinDatHang[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.ThongTinDatHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return arrC; }
/// <summary> /// vuong hung =================lay bang DonDatHang================ /// </summary> /// <returns></returns> public Entities.ThongTinDatHang[] sp_KiemKeHangHoa(Entities.TruyenGiaTri giatri) { Entities.ThongTinDatHang[] list = null; try { dh = new Constants.ThongTinDatHang(); Sql = new Constants.Sql(); string sql = "exec sp_KiemKeHangHoa @MaKho"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaKho", SqlDbType.VarChar, 20).Value = giatri.Giatritruyen; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); while (dr.Read()) { dondathang = new Entities.ThongTinDatHang(); dondathang.HanhDong = string.Empty; dondathang.MaHangHoa = dr["MaHangHoa"].ToString(); dondathang.TenHangHoa = dr["TenHangHoa"].ToString(); dondathang.GiaNhap = dr["GiaNhap"].ToString(); dondathang.Tonkho = dr["SoLuong"].ToString(); dondathang.Giabanbuon = dr["GiaBanBuon"].ToString(); dondathang.Giabanle = dr["GiaBanLe"].ToString(); dondathang.Giatrigiatang = dr["GiaTriThue"].ToString(); arr.Add(dondathang); } int n = arr.Count; if (n == 0) { list= null; } list = new Entities.ThongTinDatHang[n]; for (int i = 0; i < n; i++) { list[i] = (Entities.ThongTinDatHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); list = null; } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return list; }