public void CheckDataGridCongSL1(DataGridView dgv, string maKho) { Server_Client.Client cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select"); clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv); Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1); List <Entities.ChiTietKhoHangTheoHoaHonNhap> ctKhoList = new List <Entities.ChiTietKhoHangTheoHoaHonNhap>(); try { if (dgv.RowCount != 0) { for (int i = 0; i < dgv.RowCount; i++) { foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1) { // lay cac hang hoa da ton tai if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper())) { Entities.ChiTietKhoHangTheoHoaHonNhap ct; ct = new Entities.ChiTietKhoHangTheoHoaHonNhap("UpdateCong", maKho, dgv["MaHangHoa", i].Value.ToString(), int.Parse(dgv["SoLuong", i].Value.ToString())); ctKhoList.Add(ct); break; } } } TruSLMang(ctKhoList.ToArray()); } } catch (Exception) { } }
private void SelectHangHoa(string maKho) { try { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "ChiTietKho", new Entities.ChiTietKhoHangTheoHoaHonNhap("Select")); Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1); if (kh1 == null) { kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[0]; return; } List <Entities.ChiTietKhoHangTheoHoaHonNhap> L = new List <Entities.ChiTietKhoHangTheoHoaHonNhap>(); foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1) { if (item.Makho.ToUpper().Equals(maKho.ToUpper())) { L.Add(item); } } dgvHienThi.DataSource = L.ToArray(); FixDataGridView(); } catch { } }
private void dgvsodukhohang_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { if (dgvsodukhohang.RowCount > 0) { if (!(bool)dgvsodukhohang.Rows[0].Cells["TrangThai"].Value) { bool kt = true; for (int i = 0; i < ddh.Length; i++) { if (ddh[i].NgayKetChuyen.Month == Convert.ToInt32(cbbthang.Text) - 1 && ddh[i].NgayKetChuyen.Year.ToString() == cbbnam.Text) { kt = false; break; } } if (kt) { string maSoDuKho = dgvsodukhohang.Rows[e.RowIndex].Cells["MaSoDuKho"].Value.ToString(); string maHangHoa = dgvsodukhohang.Rows[e.RowIndex].Cells["MaHangHoa"].Value.ToString(); string makho = dgvsodukhohang.Rows[e.RowIndex].Cells["MaKho"].Value.ToString(); int sddk = Convert.ToInt32(dgvsodukhohang.Rows[e.RowIndex].Cells["SoDuDauKy"].Value.ToString()); cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.SoDuKho sodukho = new Entities.SoDuKho("Delete", 1, maSoDuKho, makho, maHangHoa, sddk, 0, datesv, 0, 0, false); clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho); bool msg = true; msg = (bool)cl.DeserializeHepper(clientstrem, msg); if (msg) { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; ctkho[0] = new Entities.ChiTietKhoHangTheoHoaHonNhap(); ctkho[0].Hanhdong = "Update"; ctkho[0].Makho = makho; ctkho[0].Mahanghoa = maHangHoa; ctkho[0].Soluong = sddk; clientstrem = cl.SerializeObj(this.client, "ThemChiTietKhoHang", ctkho); tsslma.Text = maHangHoa; tsslsodudauky.Text = sddk.ToString(); tsslten.Text = LayTenHangHoa(maHangHoa); HienThi(); } else { MessageBox.Show("Insert thất Bại"); } } } } } }
public void CheckDataGridTruSL(DataGridView dgv, string maKho) { if (dgv.RowCount != 0) { Entities.ChiTietKhoHangTheoHoaHonNhap[] cthdbh = new Entities.ChiTietKhoHangTheoHoaHonNhap[dgv.RowCount]; for (int j = 0; j < cthdbh.Length; j++) { cthdbh[j] = new Entities.ChiTietKhoHangTheoHoaHonNhap("Update", maKho, dgv[2, j].Value.ToString(), int.Parse(dgv["SoLuong", j].Value.ToString())); } TruSLMang(cthdbh); } }
public void CheckDataGridCongSL(DataGridView dgv, string maKho) { if (dgv.RowCount != 0) { try { Server_Client.Client cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select"); clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv); Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1); List<Entities.ChiTietKhoHangTheoHoaHonNhap> ctList = new List<Entities.ChiTietKhoHangTheoHoaHonNhap>(); for (int i = 0; i < dgv.RowCount; i++) { bool retVal = false; foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1) { if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper()) && maKho.Equals(item.Makho)) { retVal = true; break; } } if (!retVal) { Entities.ChiTietKhoHangTheoHoaHonNhap ct = new Entities.ChiTietKhoHangTheoHoaHonNhap(); ct.Hanhdong = "Insert"; ct.Mahanghoa = dgv["MaHangHoa", i].Value.ToString(); ct.Makho = maKho; ct.Ngaynhap = datesv; DateTime ngayHetHan = DateTime.Now; if (dgv["NgayHetHan", i] != null) ngayHetHan = (DateTime)dgv["NgayHetHan", i].Value; ct.Ngayhethan = ngayHetHan; ct.Soluong = int.Parse(dgv["SoLuong", i].Value.ToString()); ct.Ghichu = ""; ctList.Add(ct); } } Server_Client.Client cl1 = new Server_Client.Client(); this.client1 = cl1.Connect(Luu.IP, Luu.Ports); clientstrem = cl1.SerializeObj(this.client1, "ThemChiTietKhoHang", ctList.ToArray()); } catch (Exception) { } } }
public void CheckDataGridCongSL(DataGridView dgv, string maKho) { if (dgv.RowCount != 0) { try { Server_Client.Client cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select"); clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv); Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1); List <Entities.ChiTietKhoHangTheoHoaHonNhap> ctList = new List <Entities.ChiTietKhoHangTheoHoaHonNhap>(); for (int i = 0; i < dgv.RowCount; i++) { bool retVal = false; foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1) { if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper()) && maKho.Equals(item.Makho)) { retVal = true; break; } } if (!retVal) { Entities.ChiTietKhoHangTheoHoaHonNhap ct = new Entities.ChiTietKhoHangTheoHoaHonNhap(); ct.Hanhdong = "Insert"; ct.Mahanghoa = dgv["MaHangHoa", i].Value.ToString(); ct.Makho = maKho; ct.Ngaynhap = datesv; DateTime ngayHetHan = DateTime.Now; if (dgv["NgayHetHan", i] != null) { ngayHetHan = (DateTime)dgv["NgayHetHan", i].Value; } ct.Ngayhethan = ngayHetHan; ct.Soluong = int.Parse(dgv["SoLuong", i].Value.ToString()); ct.Ghichu = ""; ctList.Add(ct); } } Server_Client.Client cl1 = new Server_Client.Client(); this.client1 = cl1.Connect(Luu.IP, Luu.Ports); clientstrem = cl1.SerializeObj(this.client1, "ThemChiTietKhoHang", ctList.ToArray()); } catch (Exception) { } } }
private void toolStripButton1_Click(object sender, EventArgs e) { bool kt1 = true; for (int i = 0; i < dgvsodukhohang.RowCount; i++) { if (dgvsodukhohang.Rows[i].Cells["MaHangHoa"].Value.ToString() == tsslma.Text) { kt1 = false; break; } } if (kt1) { string ma = LayID("SoDuKho"); Entities.KhoHang kh = (Entities.KhoHang)cbbkhohang.SelectedItem; string makho = kh.MaKho; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.SoDuKho sodukho = new Entities.SoDuKho("Insert", 1, ma, makho, tsslma.Text, Convert.ToInt32(tsslsodudauky.Text), 0, datesv, 0, 0, false); clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho); bool msg = true; msg = (bool)cl.DeserializeHepper(clientstrem, msg); if (msg) { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; ctkho[0] = new Entities.ChiTietKhoHangTheoHoaHonNhap(); ctkho[0].Hanhdong = "UpdateCong"; ctkho[0].Makho = makho; ctkho[0].Mahanghoa = tsslma.Text; ctkho[0].Soluong = Convert.ToInt32(tsslsodudauky.Text); clientstrem = cl.SerializeObj(this.client, "ThemChiTietKhoHang", ctkho); int i = 0; i = (int)cl.DeserializeHepper(clientstrem, i); HienThi(); tsslma.Text = "<F4>-tra cứu"; tsslsodudauky.Text = "0"; tsslten.Text = ""; } else { MessageBox.Show("Insert thất Bại"); } } else { MessageBox.Show("Hàng Hóa đã được nhập số dư đầu kỳ - Không thể thêm mới"); } }
/// <summary> /// luu chi tiet don hang /// </summary> private void LuuChiTietDonHang() { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietHoaDonNhap[] luu = LuuChiTietHoaDonNhap(dgvInsertOrder, "Insert", txtSodonhang.Text.ToUpper()); clientstrem = cl.SerializeHepper(this.client, "ChiTietHoaDonNhap", luu); int bao = 0; bao = (int)cl.DeserializeHepper(clientstrem, bao); if (bao == 1) { int k = dgvInsertOrder.RowCount; Entities.ChiTietKhoHangTheoHoaHonNhap[] khohang = new Entities.ChiTietKhoHangTheoHoaHonNhap[k]; ArrayList arr = new ArrayList(); if (k > 0) { for (int x = 0; x < k; x++) { Entities.ChiTietKhoHangTheoHoaHonNhap kho = new Entities.ChiTietKhoHangTheoHoaHonNhap(); kho.Hanhdong = "Insert"; kho.Makho = cbxKhoHang.SelectedValue.ToString(); kho.Mahanghoa = dgvInsertOrder.Rows[x].Cells[1].Value.ToString(); kho.Soluong = System.Convert.ToInt32(dgvInsertOrder.Rows[x].Cells[3].Value.ToString()); kho.Ngaynhap = DateTime.Now; kho.Ngayhethan = 0; kho.Ghichu = txtDiengiai.Text; kho.Deleted = false; arr.Add(kho); } int n = arr.Count; if (n == 0) { khohang = null; } khohang = new Entities.ChiTietKhoHangTheoHoaHonNhap[n]; for (int j = 0; j < n; j++) { khohang[j] = (Entities.ChiTietKhoHangTheoHoaHonNhap)arr[j]; } } else { khohang = null; } LuuChiTietVaoKhoHang(khohang); } else { MessageBox.Show("Chưa thêm vào kho"); } }
public void LayChiTiet_HangHoaXuat() { try { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select"); clientstrem = cl.SerializeObj(this.client, "ChiTietKho", nv); Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1); if (kh1 == null) { ctHangHoaTheoKho = new Entities.ChiTietKhoHangTheoHoaHonNhap[0]; ctBCXH = new Entities.SoDuKho[0]; return; } ctHangHoaTheoKho = kh1; ctBCXH = new Entities.SoDuKho[ctHangHoaTheoKho.Length]; for (int i = 0; i < ctHangHoaTheoKho.Length; i++) { ctBCXH[i] = new Entities.SoDuKho(); ctBCXH[i].MaKho = ctHangHoaTheoKho[i].Makho; ctBCXH[i].MaHangHoa = ctHangHoaTheoKho[i].Mahanghoa; ctBCXH[i].SoDuDauKy = 0; ctBCXH[i].SoDuCuoiKy = 0; ctBCXH[i].PhatSinhNo = 0; ctBCXH[i].PhatSinhCo = 0; } Entities.SoDuKho[] sdk1 = LaySoDuKhoTheoNgay(Convert.ToInt32(cbbthang.Text), Convert.ToInt32(cbbnam.Text)); for (int i = 0; i < sdk1.Length; i++) { for (int j = 0; j < ctBCXH.Length; j++) { if (sdk1[i].MaKho == ctBCXH[j].MaKho && sdk1[i].MaHangHoa == ctBCXH[j].MaHangHoa) { ctBCXH[j].SoDuDauKy = sdk1[i].SoDuDauKy; } } } } catch { } }
/// <summary> /// kiểm tra dtgv trừ số lượng /// </summary> /// <param name="dgv"></param> public void CheckDataGridTruSL(Entities.ChiTietXuatHuy[] dgv) { try { if (dgv.Length != 0) { Entities.ChiTietKhoHangTheoHoaHonNhap[] cthdbh = new Entities.ChiTietKhoHangTheoHoaHonNhap[dgv.Length]; for (int j = 0; j < cthdbh.Length; j++) { string maKho = dtgvxuathuyhanghoa["MaKho", i].Value.ToString(); cthdbh[j] = new Entities.ChiTietKhoHangTheoHoaHonNhap("Update", maKho, dgv[j].MaHangHoa, dgv[j].SoLuong); } TruSLMang(cthdbh); } } catch { } }
public void LayChiTiet_HangHoaXuat() { try { Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kh1 = new ChiTietKhoHangTheoHoaHonNhap().Select(); if (kh1 == null) { ctHangHoaTheoKho = new Entities.ChiTietKhoHangTheoHoaHonNhap[0]; ctBCXH = new Entities.SoDuKho[0]; return; } ctHangHoaTheoKho = kh1; ctBCXH = new Entities.SoDuKho[ctHangHoaTheoKho.Length]; for (int i = 0; i < ctHangHoaTheoKho.Length; i++) { ctBCXH[i] = new Entities.SoDuKho(); ctBCXH[i].MaKho = ctHangHoaTheoKho[i].Makho; ctBCXH[i].MaHangHoa = ctHangHoaTheoKho[i].Mahanghoa; ctBCXH[i].SoDuDauKy = 0; ctBCXH[i].SoDuCuoiKy = 0; ctBCXH[i].PhatSinhNo = 0; ctBCXH[i].PhatSinhCo = 0; } Entities.SoDuKho[] sdk1 = LaySoDuKhoTheoNgay(DateTime.Now.Month, DateTime.Now.Year); for (int i = 0; i < sdk1.Length; i++) { for (int j = 0; j < ctBCXH.Length; j++) { if (sdk1[i].MaKho == ctBCXH[j].MaKho && sdk1[i].MaHangHoa == ctBCXH[j].MaHangHoa) { ctBCXH[j].SoDuDauKy = sdk1[i].SoDuDauKy; } } } } catch { } }
private void SelectHangHoa(string maKho) { try { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "ChiTietKho", new Entities.ChiTietKhoHangTheoHoaHonNhap("Select")); Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1); if (kh1 == null) { kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[0]; return; } List<Entities.ChiTietKhoHangTheoHoaHonNhap> L = new List<Entities.ChiTietKhoHangTheoHoaHonNhap>(); foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1) { if (item.Makho.ToUpper().Equals(maKho.ToUpper())) { L.Add(item); } } dgvHienThi.DataSource = L.ToArray(); FixDataGridView(); } catch { } }
private void dgvsodukhohang_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex>-1) { if (dgvsodukhohang.RowCount>0) { if (!(bool)dgvsodukhohang.Rows[0].Cells["TrangThai"].Value) { bool kt = true; for (int i = 0; i < ddh.Length; i++) { if (ddh[i].NgayKetChuyen.Month == Convert.ToInt32(cbbthang.Text) - 1 && ddh[i].NgayKetChuyen.Year.ToString() == cbbnam.Text) { kt = false; break; } } if (kt) { string maSoDuKho=dgvsodukhohang.Rows[e.RowIndex].Cells["MaSoDuKho"].Value.ToString(); string maHangHoa = dgvsodukhohang.Rows[e.RowIndex].Cells["MaHangHoa"].Value.ToString(); string makho = dgvsodukhohang.Rows[e.RowIndex].Cells["MaKho"].Value.ToString(); int sddk = Convert.ToInt32(dgvsodukhohang.Rows[e.RowIndex].Cells["SoDuDauKy"].Value.ToString()); cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.SoDuKho sodukho = new Entities.SoDuKho("Delete", 1, maSoDuKho,makho, maHangHoa, sddk, 0, datesv, 0, 0, false); clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho); bool msg = true; msg = (bool)cl.DeserializeHepper(clientstrem, msg); if (msg) { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; ctkho[0] = new Entities.ChiTietKhoHangTheoHoaHonNhap(); ctkho[0].Hanhdong = "Update"; ctkho[0].Makho = makho; ctkho[0].Mahanghoa = maHangHoa; ctkho[0].Soluong = sddk; clientstrem = cl.SerializeObj(this.client, "ThemChiTietKhoHang", ctkho); tsslma.Text = maHangHoa; tsslsodudauky.Text = sddk.ToString(); tsslten.Text = LayTenHangHoa(maHangHoa); HienThi(); } else { MessageBox.Show("Insert thất Bại"); } } } } } }
private void toolStripButton1_Click(object sender, EventArgs e) { bool kt1 = true; for (int i = 0; i < dgvsodukhohang.RowCount; i++) { if (dgvsodukhohang.Rows[i].Cells["MaHangHoa"].Value.ToString() == tsslma.Text) { kt1 = false; break; } } if (kt1) { string ma = LayID("SoDuKho"); Entities.KhoHang kh = (Entities.KhoHang)cbbkhohang.SelectedItem; string makho = kh.MaKho; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.SoDuKho sodukho = new Entities.SoDuKho("Insert", 1, ma,makho, tsslma.Text, Convert.ToInt32(tsslsodudauky.Text), 0, datesv, 0, 0, false); clientstrem = cl.SerializeObj(this.client, "SoDuKho", sodukho); bool msg = true; msg = (bool)cl.DeserializeHepper(clientstrem, msg); if (msg) { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; ctkho[0] = new Entities.ChiTietKhoHangTheoHoaHonNhap(); ctkho[0].Hanhdong = "UpdateCong"; ctkho[0].Makho = makho; ctkho[0].Mahanghoa = tsslma.Text; ctkho[0].Soluong = Convert.ToInt32(tsslsodudauky.Text); clientstrem = cl.SerializeObj(this.client, "ThemChiTietKhoHang", ctkho); int i = 0; i = (int)cl.DeserializeHepper(clientstrem, i); HienThi(); tsslma.Text = "<F4>-tra cứu"; tsslsodudauky.Text = "0"; tsslten.Text = ""; } else { MessageBox.Show("Insert thất Bại"); } } else MessageBox.Show("Hàng Hóa đã được nhập số dư đầu kỳ - Không thể thêm mới"); }
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(); } }
/// <summary> /// luu chi tiet don hang /// </summary> private void LuuChiTietDonHang() { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietHoaDonNhap[] luu = LuuChiTietHoaDonNhap(dgvInsertOrder, "Insert", txtSodonhang.Text.ToUpper()); clientstrem = cl.SerializeHepper(this.client, "ChiTietHoaDonNhap", luu); int bao = 0; bao = (int)cl.DeserializeHepper(clientstrem, bao); if (bao == 1) { int k = dgvInsertOrder.RowCount; Entities.ChiTietKhoHangTheoHoaHonNhap[] khohang = new Entities.ChiTietKhoHangTheoHoaHonNhap[k]; ArrayList arr = new ArrayList(); if (k > 0) { for (int x = 0; x < k; x++) { Entities.ChiTietKhoHangTheoHoaHonNhap kho = new Entities.ChiTietKhoHangTheoHoaHonNhap(); kho.Hanhdong = "Insert"; kho.Makho = cbxKhoHang.SelectedValue.ToString(); kho.Mahanghoa = dgvInsertOrder.Rows[x].Cells[1].Value.ToString(); kho.Soluong = System.Convert.ToInt32(dgvInsertOrder.Rows[x].Cells[3].Value.ToString()); kho.Ngaynhap = DateTime.Now; kho.Ngayhethan = 0; kho.Ghichu = txtDiengiai.Text; kho.Deleted = false; arr.Add(kho); } int n = arr.Count; if (n == 0) { khohang = null; } khohang = new Entities.ChiTietKhoHangTheoHoaHonNhap[n]; for (int j = 0; j < n; j++) { khohang[j] = (Entities.ChiTietKhoHangTheoHoaHonNhap)arr[j]; } } else { khohang = null;} LuuChiTietVaoKhoHang(khohang); } else { MessageBox.Show("Chưa thêm vào kho"); } }
public void CheckDataGridTruSL(DataGridView dgv) { if (dgv.RowCount != 0) { Entities.ChiTietKhoHangTheoHoaHonNhap[] cthdbh = new Entities.ChiTietKhoHangTheoHoaHonNhap[dgv.RowCount]; for (int j = 0; j < cthdbh.Length; j++) { string maKho = cbxKhoHang.SelectedValue.ToString().ToUpper(); cthdbh[j] = new Entities.ChiTietKhoHangTheoHoaHonNhap("Update", maKho, dgv[0, j].Value.ToString(), int.Parse(dgv["SoLuong", j].Value.ToString())); } TruSLMang(cthdbh); } }
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 void CheckDataGridCongSL1(DataGridView dgv, string maKho) { Server_Client.Client cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select"); clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv); Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1]; kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1); List<Entities.ChiTietKhoHangTheoHoaHonNhap> ctKhoList = new List<Entities.ChiTietKhoHangTheoHoaHonNhap>(); try { if (dgv.RowCount != 0) { for (int i = 0; i < dgv.RowCount; i++) { foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1) { // lay cac hang hoa da ton tai if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper())) { Entities.ChiTietKhoHangTheoHoaHonNhap ct; ct = new Entities.ChiTietKhoHangTheoHoaHonNhap("UpdateCong", maKho, dgv["MaHangHoa", i].Value.ToString(), int.Parse(dgv["SoLuong", i].Value.ToString())); ctKhoList.Add(ct); break; } } } TruSLMang(ctKhoList.ToArray()); } } catch (Exception) { } }