/// <summary> /// add ban ghi --------------------------------hungvv----------------------------- /// </summary> /// <param name="dgv"></param> public Entities.ChiTietHoaDonNhap[] LuuChiTietHoaDonNhap(DataGridView dgv, string hanhdong, string madondathang) { ArrayList arr = new ArrayList(); int i = dgv.RowCount; Entities.ChiTietHoaDonNhap[] mangBanghi = null; if (i > 0) { for (int x = 0; x < i; x++) { Entities.ChiTietHoaDonNhap banghi = new Entities.ChiTietHoaDonNhap(); banghi.Hanhdong = hanhdong; banghi.MaHoaDonNhap = madondathang.ToUpper(); banghi.MaHangHoa = dgv.Rows[x].Cells[1].Value.ToString(); banghi.SoLuong = System.Convert.ToInt32(dgv.Rows[x].Cells[3].Value.ToString()); banghi.PhanTramChietKhau = dgv.Rows[x].Cells[5].Value.ToString(); banghi.GhiChu = dgv.Rows[x].Cells[2].Value.ToString(); banghi.Deleted = false; arr.Add(banghi); } int n = arr.Count; if (n == 0) { return null; } mangBanghi = new Entities.ChiTietHoaDonNhap[n]; for (int j = 0; j < n; j++) { mangBanghi[j] = (Entities.ChiTietHoaDonNhap)arr[j]; } } else { mangBanghi = null; mangBanghi = null; } return mangBanghi; }
/// <summary> /// hungvv =======================giao tiep voi server=========================== /// </summary> private void Select_ChiTietHoaDonNhap(string hanhdong) { Entities.HoaDonNhap pt = new Entities.HoaDonNhap(); pt = new Entities.HoaDonNhap(hanhdong); Entities.ChiTietHoaDonNhap[] pt1 = new Entities.ChiTietHoaDonNhap[10]; clientstrem = cl.SerializeObj(this.client, "ChiTietHoaDonNhap", pt); Binding((Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper(clientstrem, pt1)); }
public void LayChiTietHoaDonNhap() { Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[0]; ctHDN1 = new BizLogic.ChiTietHoaDonNhap().Select(); if (ctHDN1 == null) { ctHDN = new Entities.ChiTietHoaDonNhap[0]; return; } else { ctHDN = ctHDN1; } }
public void LayChiTietHoaDonNhap() { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.CheckRefer ctxh = new Entities.CheckRefer("CTHDN", ""); clientstrem = cl.SerializeObj(this.client, "Select", ctxh); Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[0]; ctHDN1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, ctHDN1); if (ctHDN1 == null) { ctHDN = new Entities.ChiTietHoaDonNhap[0]; return; } else { ctHDN = ctHDN1; } }
/// <summary> /// add ban ghi --------------------------------hungvv----------------------------- /// </summary> /// <param name="dgv"></param> public Entities.ChiTietHoaDonNhap[] LuuChiTietHoaDonNhap(DataGridView dgv, string hanhdong, string madondathang) { ArrayList arr = new ArrayList(); int i = dgv.RowCount; Entities.ChiTietHoaDonNhap[] mangBanghi = null; if (i > 0) { for (int x = 0; x < i; x++) { Entities.ChiTietHoaDonNhap banghi = new Entities.ChiTietHoaDonNhap(); banghi.Hanhdong = hanhdong; banghi.MaHoaDonNhap = madondathang.ToUpper(); banghi.MaHangHoa = dgv.Rows[x].Cells[1].Value.ToString(); banghi.SoLuong = System.Convert.ToInt32(dgv.Rows[x].Cells[3].Value.ToString()); banghi.PhanTramChietKhau = dgv.Rows[x].Cells[5].Value.ToString(); banghi.GhiChu = dgv.Rows[x].Cells[2].Value.ToString(); banghi.Deleted = false; arr.Add(banghi); } int n = arr.Count; if (n == 0) { return(null); } mangBanghi = new Entities.ChiTietHoaDonNhap[n]; for (int j = 0; j < n; j++) { mangBanghi[j] = (Entities.ChiTietHoaDonNhap)arr[j]; } } else { mangBanghi = null; mangBanghi = null; } return(mangBanghi); }
public Entities.ChiTietHoaDonNhap[] LayChiTietHoaDonNhap_TheoMaHD(string maHDNhap) { if (ctHDN.Length == 0) { return(new Entities.ChiTietHoaDonNhap[0]); } else { int count = 0; for (int i = 0; i < ctHDN.Length; i++) { if (ctHDN[i].MaHoaDonNhap == maHDNhap) { count++; } } Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[count]; count = 0; for (int i = 0; i < ctHDN.Length; i++) { if (ctHDN[i].MaHoaDonNhap == maHDNhap) { ctHDN1[count] = ctHDN[i]; count++; } } if (ctHDN1.Length == 0) { return(new Entities.ChiTietHoaDonNhap[0]); } else { return(ctHDN1); } } }
public void HienThiChiTiet(string maHDNhap, string makho) { try { cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietHoaDonNhap[] kh = new Entities.ChiTietHoaDonNhap[1]; kh[0] = new Entities.ChiTietHoaDonNhap("Select"); clientstrem = cl.SerializeObj(this.client1, "ChiTietHoaDonNhap", kh); Entities.ChiTietHoaDonNhap[] kh1 = new Entities.ChiTietHoaDonNhap[1]; kh1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, kh1); if (kh1.Length > 0) { int ctcount = 0; foreach (Entities.ChiTietHoaDonNhap h in kh1) { if (h.MaHoaDonNhap == maHDNhap) { ctcount++; } } Entities.ChiTietHoaDonNhap[] hdn = new Entities.ChiTietHoaDonNhap[ctcount]; ctcount = 0; foreach (Entities.ChiTietHoaDonNhap h in kh1) { if (h.MaHoaDonNhap == maHDNhap) { hdn[ctcount] = new Entities.ChiTietHoaDonNhap(); hdn[ctcount].MaHangHoa = h.MaHangHoa; hdn[ctcount].SoLuong = h.SoLuong; ctcount++; } } Server_Client.Client cl1 = new Server_Client.Client(); this.client1 = cl1.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap[] kho = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kho[0] = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select"); clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", kho); Entities.ChiTietKhoHangTheoHoaHonNhap[] kho1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kho1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kho1); Entities.ChiTietPhieuDieuChuyenKho[] ctdck = new Entities.ChiTietPhieuDieuChuyenKho[ctcount]; for (int i = 0; i < ctdck.Length; i++) { ctdck[i] = new Entities.ChiTietPhieuDieuChuyenKho(); ctdck[i].MaHangHoa = hdn[i].MaHangHoa; ctdck[i].SoLuong = hdn[i].SoLuong; ctdck[i].MaPhieuDieuChuyenKho = txtSochungtu.Text; if (kho1 != null) { for (int j = 0; j < kho1.Length; j++) { if (kho1[j].Makho == makho & kho1[j].Mahanghoa == hdn[i].MaHangHoa) { ctdck[i].NgayHetHan = kho1[j].Ngayhethan; break; } } } } for (int i = 0; i < ctcount; i++) { arr.Add(ctdck[i]); } arrct = new Entities.ChiTietPhieuDieuChuyenKho[ctcount]; for (int i = 0; i < ctcount; i++) { arrct[i] = ctdck[i]; } LayBangHangHoa(); for (int i = 0; i < ctdck.Length; i++) { for (int j = 0; j < hanghoa.Length; j++) { if (hanghoa[j].MaHangHoa == ctdck[i].MaHangHoa) { ctdck[i].TenHangHoa = hanghoa[j].TenHangHoa; break; } } } CtPdck_BaoCao = ctdck; dgvInsertOrder.DataSource = ctdck; FixDataGridView(); } } catch { } }
public Entities.ChiTietHoaDonNhap[] LayChiTietHoaDonNhap_TheoMaHD(string maHDNhap) { if (ctHDN.Length == 0) { return new Entities.ChiTietHoaDonNhap[0]; } else { int count = 0; for (int i = 0; i < ctHDN.Length; i++) { if (ctHDN[i].MaHoaDonNhap == maHDNhap) { count++; } } Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[count]; count = 0; for (int i = 0; i < ctHDN.Length; i++) { if (ctHDN[i].MaHoaDonNhap == maHDNhap) { ctHDN1[count] = ctHDN[i]; count++; } } if (ctHDN1.Length == 0) { return new Entities.ChiTietHoaDonNhap[0]; } else return ctHDN1; } }
public void LayChiTietHoaDonNhap() { Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[0]; ctHDN1 = new BizLogic.ChiTietHoaDonNhap().Select(); if (ctHDN1 == null) { ctHDN = new Entities.ChiTietHoaDonNhap[0]; return; } else ctHDN = ctHDN1; }
public Entities.BCNhapHangTheoNhomHang Select() { Entities.BCNhapHangTheoNhomHang list = null; try { list = new Entities.BCNhapHangTheoNhomHang(); ////Lấy hóa đơn nhập //con = new Connection(); //cn = con.openConnection(); //List<Entities.HoaDonNhap> HoaDonNhap = new List<Entities.HoaDonNhap>(); //cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); //cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "HoaDonNhap"; //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //while (dr.Read()) //{ // Entities.HoaDonNhap row = new Entities.HoaDonNhap(); // row.MaHoaDonNhap = dr["MaHoaDonNhap"].ToString(); // row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString()); // HoaDonNhap.Add(row); //} //list.HoaDonNhap = HoaDonNhap; //cmd.Connection.Dispose(); //cn.Close(); //con.closeConnection(); //Lấy chi tiết hóa đơn nhập con = new Connection(); cn = con.openConnection(); List <Entities.ChiTietHoaDonNhap> ChiTietHoaDonNhap = new List <Entities.ChiTietHoaDonNhap>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietHoaDonNhap"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.ChiTietHoaDonNhap row = new Entities.ChiTietHoaDonNhap(); row.MaHoaDonNhap = dr["MaHoaDonNhap"].ToString(); row.MaHangHoa = dr["MaHangHoa"].ToString(); row.SoLuong = int.Parse(dr["SoLuong"].ToString()); row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString()); ChiTietHoaDonNhap.Add(row); } list.ChiTietHoaDonNhap = ChiTietHoaDonNhap; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); ////Lấy khách hàng trả lại //con = new Connection(); //cn = con.openConnection(); //List<Entities.KhachHangTraLai> KhachHangTraLai = new List<Entities.KhachHangTraLai>(); //cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); //cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "KhachHangTraLai"; //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //while (dr.Read()) //{ // Entities.KhachHangTraLai row = new Entities.KhachHangTraLai(); // row.MaKhachHangTraLai = dr["MaKhachHangTraLai"].ToString(); // row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString()); // KhachHangTraLai.Add(row); //} //list.KhachHangTraLai = KhachHangTraLai; //cmd.Connection.Dispose(); //cn.Close(); //con.closeConnection(); //Lấy chi tiết khách hàng trả lại con = new Connection(); cn = con.openConnection(); List <Entities.ChiTietKhachHangTraLai> ChiTietKhachHangTraLai = new List <Entities.ChiTietKhachHangTraLai>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietKhachHangTraLai"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.ChiTietKhachHangTraLai row = new Entities.ChiTietKhachHangTraLai(); row.MaKhachHangTraLai = dr["MaKhachHangTraLai"].ToString(); row.MaHangHoa = dr["MaHangHoa"].ToString(); row.SoLuong = int.Parse(dr["SoLuong"].ToString()); row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString()); ChiTietKhachHangTraLai.Add(row); } list.ChiTietKhachHangTraLai = ChiTietKhachHangTraLai; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); //Lấy hàng hóa nhóm hàng con = new Connection(); cn = con.openConnection(); List <Entities.HangHoa> HangHoa = new List <Entities.HangHoa>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "HangHoaNhomHang"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.HangHoa row = new Entities.HangHoa(); row.MaHangHoa = dr["MaHangHoa"].ToString(); row.TenHangHoa = dr["TenHangHoa"].ToString(); row.MaNhomHangHoa = dr["MaNhomHang"].ToString(); row.TenNhomHangHoa = dr["TenNhomHang"].ToString(); HangHoa.Add(row); } list.HangHoa = HangHoa; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); //Lấy nhóm hàng con = new Connection(); cn = con.openConnection(); List <Entities.NhomHang> NhomHang = new List <Entities.NhomHang>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "NhomHang"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.NhomHang row = new Entities.NhomHang(); row.MaNhomHang = dr["MaNhomHang"].ToString(); row.TenNhomHang = dr["TenNhomHang"].ToString(); NhomHang.Add(row); } list.NhomHang = NhomHang; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); //Lấy gói hàng con = new Connection(); cn = con.openConnection(); List <Entities.GoiHang> GoiHang = new List <Entities.GoiHang>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "GoiHang"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.GoiHang row = new Entities.GoiHang(); row.MaGoiHang = dr["MaGoiHang"].ToString(); GoiHang.Add(row); } list.GoiHang = GoiHang; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); //Lấy chi tiết gói hàng con = new Connection(); cn = con.openConnection(); List <Entities.ChiTietGoiHang> ChiTietGoiHang = new List <Entities.ChiTietGoiHang>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietGoiHang"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.ChiTietGoiHang row = new Entities.ChiTietGoiHang(); row.MaGoiHang = dr["MaGoiHang"].ToString(); row.MaHangHoa = dr["MaHangHoa"].ToString(); row.SoLuong = int.Parse(dr["SoLuong"].ToString()); ChiTietGoiHang.Add(row); } list.ChiTietGoiHang = ChiTietGoiHang; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); } catch { return(null); } finally { cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); } return(list); }
public void HienThiChiTiet(string maHDNhap, string makho) { cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietHoaDonNhap[] kh = new Entities.ChiTietHoaDonNhap[1]; kh[0] = new Entities.ChiTietHoaDonNhap("Select"); clientstrem = cl.SerializeObj(this.client1, "ChiTietHoaDonNhap", kh); Entities.ChiTietHoaDonNhap[] kh1 = new Entities.ChiTietHoaDonNhap[1]; kh1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, kh1); if (kh1.Length > 0) { int ctcount = 0; foreach (Entities.ChiTietHoaDonNhap h in kh1) { if (h.MaHoaDonNhap == maHDNhap) { ctcount++; } } Entities.ChiTietHoaDonNhap[] hdn = new Entities.ChiTietHoaDonNhap[ctcount]; ctcount = 0; foreach (Entities.ChiTietHoaDonNhap h in kh1) { if (h.MaHoaDonNhap == maHDNhap) { hdn[ctcount] = new Entities.ChiTietHoaDonNhap(); hdn[ctcount].MaHangHoa = h.MaHangHoa; hdn[ctcount].TenHangHoa = h.TenHangHoa; hdn[ctcount].SoLuong = h.SoLuong; ctcount++; } } Server_Client.Client cl1 = new Server_Client.Client(); this.client1 = cl1.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkh = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; ctkh[0] = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select"); clientstrem = cl1.SerializeObj(this.client1, "ChiTietKho", ctkh); Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; ctkh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl1.DeserializeHepper1(clientstrem, kh1); Entities.ChiTietPhieuDieuChuyenKho[] ctdck = new Entities.ChiTietPhieuDieuChuyenKho[ctcount]; for (int i = 0; i < ctdck.Length; i++) { ctdck[i] = new Entities.ChiTietPhieuDieuChuyenKho(); ctdck[i].MaHangHoa = hdn[i].MaHangHoa; ctdck[i].TenHangHoa = hdn[i].TenHangHoa; ctdck[i].SoLuong = hdn[i].SoLuong; ctdck[i].MaPhieuDieuChuyenKho = txtSochungtu.Text; if (ctkh1 != null) { for (int j = 0; j < ctkh1.Length; j++) { if (ctkh1[j].Makho == makho && hdn[i].MaHangHoa == ctkh1[j].Mahanghoa) { ctdck[i].NgayHetHan = ctkh1[i].Ngayhethan; } } } } dgvInsertOrder.DataSource = ctdck; FixDataGridView(); } }
public Entities.BCNhapHangTheoNhomHang Select() { Entities.BCNhapHangTheoNhomHang list = null; try { list = new Entities.BCNhapHangTheoNhomHang(); ////Lấy hóa đơn nhập //con = new Connection(); //cn = con.openConnection(); //List<Entities.HoaDonNhap> HoaDonNhap = new List<Entities.HoaDonNhap>(); //cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); //cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "HoaDonNhap"; //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //while (dr.Read()) //{ // Entities.HoaDonNhap row = new Entities.HoaDonNhap(); // row.MaHoaDonNhap = dr["MaHoaDonNhap"].ToString(); // row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString()); // HoaDonNhap.Add(row); //} //list.HoaDonNhap = HoaDonNhap; //cmd.Connection.Dispose(); //cn.Close(); //con.closeConnection(); //Lấy chi tiết hóa đơn nhập con = new Connection(); cn = con.openConnection(); List<Entities.ChiTietHoaDonNhap> ChiTietHoaDonNhap = new List<Entities.ChiTietHoaDonNhap>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietHoaDonNhap"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.ChiTietHoaDonNhap row = new Entities.ChiTietHoaDonNhap(); row.MaHoaDonNhap = dr["MaHoaDonNhap"].ToString(); row.MaHangHoa = dr["MaHangHoa"].ToString(); row.SoLuong = int.Parse(dr["SoLuong"].ToString()); row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString()); ChiTietHoaDonNhap.Add(row); } list.ChiTietHoaDonNhap = ChiTietHoaDonNhap; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); ////Lấy khách hàng trả lại //con = new Connection(); //cn = con.openConnection(); //List<Entities.KhachHangTraLai> KhachHangTraLai = new List<Entities.KhachHangTraLai>(); //cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); //cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "KhachHangTraLai"; //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //while (dr.Read()) //{ // Entities.KhachHangTraLai row = new Entities.KhachHangTraLai(); // row.MaKhachHangTraLai = dr["MaKhachHangTraLai"].ToString(); // row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString()); // KhachHangTraLai.Add(row); //} //list.KhachHangTraLai = KhachHangTraLai; //cmd.Connection.Dispose(); //cn.Close(); //con.closeConnection(); //Lấy chi tiết khách hàng trả lại con = new Connection(); cn = con.openConnection(); List<Entities.ChiTietKhachHangTraLai> ChiTietKhachHangTraLai = new List<Entities.ChiTietKhachHangTraLai>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietKhachHangTraLai"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.ChiTietKhachHangTraLai row = new Entities.ChiTietKhachHangTraLai(); row.MaKhachHangTraLai = dr["MaKhachHangTraLai"].ToString(); row.MaHangHoa = dr["MaHangHoa"].ToString(); row.SoLuong = int.Parse(dr["SoLuong"].ToString()); row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString()); ChiTietKhachHangTraLai.Add(row); } list.ChiTietKhachHangTraLai = ChiTietKhachHangTraLai; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); //Lấy hàng hóa nhóm hàng con = new Connection(); cn = con.openConnection(); List<Entities.HangHoa> HangHoa = new List<Entities.HangHoa>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "HangHoaNhomHang"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.HangHoa row = new Entities.HangHoa(); row.MaHangHoa = dr["MaHangHoa"].ToString(); row.TenHangHoa = dr["TenHangHoa"].ToString(); row.MaNhomHangHoa = dr["MaNhomHang"].ToString(); row.TenNhomHangHoa = dr["TenNhomHang"].ToString(); HangHoa.Add(row); } list.HangHoa = HangHoa; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); //Lấy nhóm hàng con = new Connection(); cn = con.openConnection(); List<Entities.NhomHang> NhomHang = new List<Entities.NhomHang>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "NhomHang"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.NhomHang row = new Entities.NhomHang(); row.MaNhomHang = dr["MaNhomHang"].ToString(); row.TenNhomHang = dr["TenNhomHang"].ToString(); NhomHang.Add(row); } list.NhomHang = NhomHang; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); //Lấy gói hàng con = new Connection(); cn = con.openConnection(); List<Entities.GoiHang> GoiHang = new List<Entities.GoiHang>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "GoiHang"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.GoiHang row = new Entities.GoiHang(); row.MaGoiHang = dr["MaGoiHang"].ToString(); GoiHang.Add(row); } list.GoiHang = GoiHang; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); //Lấy chi tiết gói hàng con = new Connection(); cn = con.openConnection(); List<Entities.ChiTietGoiHang> ChiTietGoiHang = new List<Entities.ChiTietGoiHang>(); cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn); cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietGoiHang"; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.ChiTietGoiHang row = new Entities.ChiTietGoiHang(); row.MaGoiHang = dr["MaGoiHang"].ToString(); row.MaHangHoa = dr["MaHangHoa"].ToString(); row.SoLuong = int.Parse(dr["SoLuong"].ToString()); ChiTietGoiHang.Add(row); } list.ChiTietGoiHang = ChiTietGoiHang; cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); } catch { return null; } finally { cmd.Connection.Dispose(); cn.Close(); con.closeConnection(); } return list; }
public void LayChiTietHoaDonNhap() { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.CheckRefer ctxh = new Entities.CheckRefer("CTHDN", ""); clientstrem = cl.SerializeObj(this.client, "Select", ctxh); Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[0]; ctHDN1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, ctHDN1); if (ctHDN1 == null) { ctHDN = new Entities.ChiTietHoaDonNhap[0]; return; } else ctHDN = ctHDN1; }