/// <summary> /// hungvv =================sua==================== /// </summary> /// <returns></returns> private Entities.DonDatHang getDatagridview() { Entities.DonDatHang dathang = new Entities.DonDatHang(); try { int x = dgvHienThi.RowCount; int y = dgvHienThi.ColumnCount; if (y <= -1 || x <= -1) { } else { int vitri = dgvHienThi.CurrentRow.Index; dathang.MaDonDatHang = "" + dgvHienThi.Rows[vitri].Cells[2].Value.ToString(); dathang.LoaiDonDatHang = Convert.ToBoolean("" + dgvHienThi.Rows[vitri].Cells[3].Value.ToString()); dathang.NgayDonHang = Convert.ToDateTime("" + dgvHienThi.Rows[vitri].Cells[4].Value.ToString()); dathang.MaNhaCungCap = "" + dgvHienThi.Rows[vitri].Cells[5].Value.ToString(); dathang.NoHienThoi = dgvHienThi.Rows[vitri].Cells[6].Value.ToString(); dathang.TrangThaiDonDatHang = "" + dgvHienThi.Rows[vitri].Cells[7].Value.ToString(); dathang.NgayNhapDuKien = Convert.ToDateTime("" + dgvHienThi.Rows[vitri].Cells[8].Value.ToString()); dathang.DieuKienThanhToan = "" + dgvHienThi.Rows[vitri].Cells[9].Value.ToString(); dathang.HinhThucThanhToan = "" + dgvHienThi.Rows[vitri].Cells[10].Value.ToString(); dathang.MaKho = "" + dgvHienThi.Rows[vitri].Cells[11].Value.ToString(); dathang.MaNhanVien = "" + dgvHienThi.Rows[vitri].Cells[12].Value.ToString(); dathang.MaTienTe = "" + dgvHienThi.Rows[vitri].Cells[13].Value.ToString(); dathang.ThueGTGT = dgvHienThi.Rows[vitri].Cells[14].Value.ToString(); dathang.Phivanchuyen = dgvHienThi.Rows[vitri].Cells[15].Value.ToString(); dathang.PhiKhac = dgvHienThi.Rows[vitri].Cells[16].Value.ToString(); dathang.GhiChu = "" + dgvHienThi.Rows[vitri].Cells[17].Value.ToString(); } } catch (Exception) { } return(dathang); }
/// <summary> /// hungvv =======================Xoa =========================== /// </summary> private void DeleteData(string ID) { try { dh = new Entities.DonDatHang(); cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); dh = new Entities.DonDatHang("Delete", ID); clientstrem = cl.SerializeObj(this.client, "DonDatHang", dh); int trave = 0; trave = System.Convert.ToInt32(cl.DeserializeHepper(clientstrem, trave)); client.Close(); clientstrem.Close(); if (trave == 1) { SelectData(); MessageBox.Show("Thành công !"); } if (trave == 0) { MessageBox.Show("Thất bại !"); } } catch (Exception) { } }
/// <summary> /// hungvv =======================Xoa =========================== /// </summary> private void DeleteData(string ID) { try { dh = new Entities.DonDatHang(); cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); dh = new Entities.DonDatHang("Delete", ID); dh.Manhanvien = Common.Utilities.User.MaNV; dh.Tendangnhap = Common.Utilities.User.TenDangNhap; clientstrem = cl.SerializeObj(this.client, "DonDatHang", dh); int trave = 0; trave = System.Convert.ToInt32(cl.DeserializeHepper(clientstrem, trave)); client.Close(); clientstrem.Close(); if (trave >= 1) { SelectData(); if (dgvHienThi.RowCount <= 0) { search = null; } } else { MessageBox.Show("Thất bại !"); } } catch (Exception ex) { string s = ex.Message; } }
/// <summary> /// xoa don dat hang /// </summary> /// <param name="madondathang"></param> private void Xoa_DonDatHang(string madondathang) { System.Windows.Forms.DialogResult giatri = System.Windows.Forms.MessageBox.Show("Bạn chắc chắn muốn xóa không ?", "Thông Báo", System.Windows.Forms.MessageBoxButtons.YesNo); { if (giatri == System.Windows.Forms.DialogResult.Yes) { Entities.DonDatHang them = new Entities.DonDatHang(); them = new Entities.DonDatHang("Delete", madondathang); clientstrem = cl.SerializeObj(this.client, "DonDatHang", them); Entities.DonDatHang[] tralai = new Entities.DonDatHang[1]; int trave = (int)cl.DeserializeHepper(clientstrem, tralai); if (trave == 1) { MessageBox.Show("Thành công !"); } else { MessageBox.Show("Thất bại !"); } } else { } } }
/// <summary> /// hungvv =======================giao tiep voi server=========================== /// </summary> private void SelectData() { try { dgvHienThi.DataSource = null; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); dh = new Entities.DonDatHang("Select", ""); clientstrem = cl.SerializeObj(this.client, "DonDatHang", dh); Entities.DonDatHang[] ddh = new Entities.DonDatHang[1]; ddh = (Entities.DonDatHang[])cl.DeserializeHepper(clientstrem, ddh); if (ddh.Length > 0) { search = ddh; dgvHienThi.DataSource = search; rdoTatca.Checked = true; } else { Entities.DonDatHang[] lay = new Entities.DonDatHang[0]; dgvHienThi.DataSource = lay; search = null; toolStripStatus_Sua.Enabled = false; } FixDataGridview(dgvHienThi); } catch (Exception ex) { string s = ex.Message.ToString(); Entities.DonDatHang[] lay = new Entities.DonDatHang[0]; dgvHienThi.DataSource = lay; FixDataGridview(dgvHienThi); } }
/// <summary> /// select dữ liệu từ server /// </summary> public void SelectData() { try { dtgvKH.RowHeadersVisible = false; Server_Client.Client cl = new Server_Client.Client(); // gán TCPclient this.client1 = cl.Connect(Luu.IP, Luu.Ports); // khởi tạo biến truyền vào với hàm khởi tạo Entities.DonDatHang kh = new Entities.DonDatHang("SelectDDH"); // khởi tạo mảng đối tượng để hứng giá trị Entities.DonDatHang[] kh1 = new Entities.DonDatHang[1]; clientstrem = cl.SerializeObj(this.client1, "DonDatHang", kh); // đổ mảng đối tượng vào datagripview kh1 = (Entities.DonDatHang[])cl.DeserializeHepper1(clientstrem, kh1); if (kh1 == null) { hienthi = new Entities.DonDatHang[0]; dtgvKH.DataSource = hienthi; return; } Entities.DonDatHang[] kh2 = new Entities.DonDatHang[kh1.Length]; int sotang = 0; for (int j = 0; j < kh1.Length; j++) { if (kh1[j].Makhachhang == str1) { kh2[sotang] = kh1[j]; sotang++; } } hienthi = new Entities.DonDatHang[sotang]; if (sotang != 0) { for (int j = 0; j < sotang; j++) { hienthi[j] = kh2[j]; } } else { hienthi = new Entities.DonDatHang[0]; dtgvKH.DataSource = new Entities.DonDatHang[0]; return; } dtgvKH.DataSource = hienthi; dtgvKH.Rows[0].Selected = true; } catch (Exception ex) { } finally { fix(); } }
private void capnhat(DataGridView dgv) { try { Entities.DonDatHang[] k = new Entities.DonDatHang[0]; dgv.DataSource = k; } catch (Exception ex) { string s = ex.Message; } }
/// <summary> /// hungvv kiem tra dinh dang khi them moi hoa don /// </summary> /// <param name="maDonDatHang"></param> private Boolean CheckData(Entities.DonDatHang dat) { if (dat.MaDonDatHang.Length <= 0) { txtSodonhang.Focus(); System.Windows.Forms.MessageBox.Show("Hãy nhập mã đơn đặt hàng"); return(false); } else { if (dat.MaNhaCungCap.Length <= 0) { txtManhacungcap.Focus(); MessageBox.Show("Kiểm tra mã nhà cung cấp"); return(false); } else { if (dat.DieuKienThanhToan.Length <= 0) { cbxDieukienthanhtoan.Focus(); MessageBox.Show("Chọn điều kiện thanh toán"); return(false); } else { if (dat.MaKho.Length <= 0) { cbxMaKho.Focus(); MessageBox.Show("Chọn mã kho"); return(false); } else { if (dat.MaTienTe.Length <= 0) { cbxTiente_Tygia.Focus(); MessageBox.Show("Loại tiền tệ không đúng"); return(false); } else { return(true); } } } } } }
private void txttimkiem_TextChanged(object sender, EventArgs e) { try { if (rdbtimkiem3.Checked == true) { return; } if (txttimkiem.Text.Length == 0) { dtgvKH.DataSource = new Entities.DonDatHang[0]; return; } int soluong = 0; if (rdbtimkiem2.Checked == true) { for (int i = 0; i < hienthi.Length; i++) { int kiemtra = hienthi[i].MaDonDatHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper()); if (kiemtra >= 0) { soluong++; } } if (soluong == 0) { dtgvKH.DataSource = new Entities.DonDatHang[0]; return; } Entities.DonDatHang[] hienthitheoma = new Entities.DonDatHang[soluong]; soluong = 0; for (int i = 0; i < hienthi.Length; i++) { int kiemtra = hienthi[i].MaDonDatHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper()); if (kiemtra >= 0) { hienthitheoma[soluong] = hienthi[i]; soluong++; } } dtgvKH.DataSource = hienthitheoma; } } finally { fix(); } }
/// <summary> /// hungvv =======================giao tiep voi server=========================== /// </summary> private void SelectData() { try { dgvHienThi.DataSource = null; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); dh = new Entities.DonDatHang("Select"); clientstrem = cl.SerializeObj(this.client, "DonDatHang", dh); Entities.DonDatHang[] ddh = new Entities.DonDatHang[1]; ddh = (Entities.DonDatHang[])cl.DeserializeHepper(clientstrem, ddh); dgvHienThi.DataSource = ddh; dgvHienThi.Columns[0].HeaderText = "STT"; dgvHienThi.Columns[0].Width = 10; dgvHienThi.Columns[1].Visible = false; dgvHienThi.Columns[2].HeaderText = "Mã đơn đặt hàng"; dgvHienThi.Columns[3].Visible = false; dgvHienThi.Columns[4].HeaderText = "Ngày đơn hàng "; dgvHienThi.Columns[5].Visible = false; dgvHienThi.Columns[6].Visible = false; dgvHienThi.Columns[7].Visible = false; dgvHienThi.Columns[8].HeaderText = "Ngày dự kiến"; dgvHienThi.Columns[9].Visible = false; dgvHienThi.Columns[10].Visible = false; dgvHienThi.Columns[11].Visible = false; dgvHienThi.Columns[12].Visible = false; dgvHienThi.Columns[13].Visible = false; dgvHienThi.Columns[17].HeaderText = "Thuế GTGT"; dgvHienThi.Columns[15].Visible = false; dgvHienThi.Columns[16].Visible = false; dgvHienThi.Columns[17].HeaderText = "Ghi chú"; dgvHienThi.Columns[18].Visible = false; new Common.Utilities().CountDatagridview(dgvHienThi); dgvHienThi.RowHeadersVisible = false; dgvHienThi.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvHienThi.SelectionMode = DataGridViewSelectionMode.FullRowSelect; } catch (Exception ex) { string s = ex.Message.ToString(); MessageBox.Show("Lỗi hiển thị dữ liệu"); } }
/// <summary> /// do du lieu vao dgv /// </summary> private void HienThi_ChiTiet_DonDatHang() { try { Entities.DonDatHang dat = new Entities.DonDatHang(); dat.Hanhdong = "Select"; dat.MaNhaCungCap = GiaTriCanLuu.Ma.ToString().ToUpper(); cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "HienThi_ChiTiet_DonDatHang", dat); Entities.HienThi_ChiTiet_DonDatHang[] ddh = new Entities.HienThi_ChiTiet_DonDatHang[1]; ddh = (Entities.HienThi_ChiTiet_DonDatHang[])cl.DeserializeHepper(clientstrem, ddh); dgvInsertOrder.DataSource = ddh; DoiTen(dgvInsertOrder); } catch (Exception) { } client.Close(); clientstrem.Close(); }
/// <summary> /// cap nhat lai trang thai don dat hang /// </summary> private void CapNhatTrangThaiDonDatHang(string hanhdong, string MaDonDatHang, string trangthai) { if (MaDonDatHang.Length > 0) { Entities.DonDatHang dat = new Entities.DonDatHang(); dat.Hanhdong = hanhdong; dat.MaDonDatHang = MaDonDatHang; dat.TrangThaiDonDatHang = trangthai; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "CapNhatTrangThaiDonDatHang", dat); string tralai = ""; tralai = (string)cl.DeserializeHepper(clientstrem, tralai); //if (tralai == "OK") //{ MessageBox.Show("cap nhat thanh cong"); } //else //{ MessageBox.Show("Chưa thêm vào kho"); } } else { } }
/// <summary> /// hungvv =================do du lieu vao txt=========================== /// </summary> /// <param name="dat"></param> private void DoDuLieu(Entities.DonDatHang dat) { Common.Utilities com = new Common.Utilities(); txtSodonhang.Text = dat.MaDonDatHang; txtManhacungcap.Text = dat.MaNhaCungCap; GiaTriCanLuu.Ma = dat.MaNhaCungCap; txtTrangthaidonhang.Text = dat.TrangThaiDonDatHang; cbxDieukienthanhtoan.SelectedValue = dat.DieuKienThanhToan; cbxMaKho.Text = dat.MaKho; makNgaydonhang.Text = com.XuLy(2, this.dathang.NgayDonHang.ToString()); makNgaynhapdukien.Text = com.XuLy(2, this.dathang.NgayNhapDuKien.ToString()); txtNohienthoi.Text = dat.NoHienThoi.ToString(); txtPhuongthucvanchuyen.Text = dat.ToString(); cbxDieukienthanhtoan.SelectedItem = dat.DieuKienThanhToan.ToString(); cbxHinhthucthanhtoan.SelectedItem = dat.HinhThucThanhToan.ToString(); cbxNhanvien.SelectedValue = dat.MaNhanVien.ToString(); check_loaidathang.Checked = dat.LoaiDonDatHang; cbxTiente_Tygia.SelectedValue = dat.MaTienTe.ToString(); txtDiengiai.Text = dat.GhiChu; txtPhikhac.Text = dat.PhiKhac.ToString(); txtPhivanchuyen.Text = dat.Phivanchuyen.ToString(); HienThi_ChiTiet_DonDatHang(); }
/// <summary> /// hungvv =======================Xoa =========================== /// </summary> private void DeleteData(string ID) { try { Entities.DonDatHang dh = new Entities.DonDatHang(); cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); dh = new Entities.DonDatHang("Delete", ID); clientstrem = cl.SerializeObj(this.client, "DonDatHang", dh); int trave = 0; trave = System.Convert.ToInt32(cl.DeserializeHepper(clientstrem, trave)); client.Close(); clientstrem.Close(); } catch (Exception ex) { string s = ex.Message; } }
/// <summary> /// hungvv =======================lay du lieu moi checkfix=========================== /// </summary> private Entities.DonDatHang ConfilickData(string table, string values) { Entities.DonDatHang ddh = new Entities.DonDatHang(); try { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.TruyenGiaTri gitri = new Entities.TruyenGiaTri("Select", table, values); clientstrem = cl.SerializeObj(this.client, "CheckDonDatHang", gitri); ddh = (Entities.DonDatHang)cl.DeserializeHepper(clientstrem, ddh); } catch (Exception ex) { string s = ex.Message.ToString(); ddh = null; } return ddh; }
/// <summary> /// them moi, sua thong tin don dat hang /// </summary> /// <param name="hanhdong"></param> private void XuLy_DonDatHang(string hanhdong) { try { Entities.DonDatHang don = new Entities.DonDatHang(); string thoigian_1 = null; thoigian_1 = new Common.Utilities().MyDateConversion(makNgaydonhang.Text); string thoigian_2 = null; thoigian_2 = new Common.Utilities().MyDateConversion(makNgaynhapdukien.Text); if (thoigian_1 != null && thoigian_2 != null) { don.NgayDonHang = DateTime.Parse(thoigian_1); thoigian_1 = null; don.NgayNhapDuKien = DateTime.Parse(thoigian_2); thoigian_2 = null; don.Hanhdong = hanhdong; don.MaDonDatHang = "" + txtSodonhang.Text.ToUpper(); don.LoaiDonDatHang = check_loaidathang.Checked; don.MaNhaCungCap = "" + txtManhacungcap.Text.ToUpper(); don.NoHienThoi = txtNohienthoi.Text.ToString(); don.TrangThaiDonDatHang = "" + txtTrangthaidonhang.Text.ToString(); don.DieuKienThanhToan = "" + cbxDieukienthanhtoan.SelectedItem.ToString();; don.HinhThucThanhToan = "" + cbxHinhthucthanhtoan.SelectedItem.ToString(); don.MaKho = "" + cbxMaKho.SelectedValue.ToString().ToUpper(); don.MaNhanVien = cbxNhanvien.SelectedValue.ToString().ToUpper(); don.MaTienTe = "" + cbxTiente_Tygia.SelectedValue.ToString().ToUpper(); don.ThueGTGT = txtGiatrigiatang.Text; don.Phivanchuyen = txtPhivanchuyen.Text; don.PhiKhac = txtPhikhac.Text; don.GhiChu = "" + txtDiengiai.Text.ToString(); don.Deleted = false; if (dgvInsertOrder.RowCount > 0) { if (CheckData(don) == true) { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "DonDatHang", don); Entities.DonDatHang[] tralai = new Entities.DonDatHang[1]; int trave = Convert.ToInt32(cl.DeserializeHepper(clientstrem, tralai)); if (trave == 1) { LuuChiTietDonHang(); MessageBox.Show("Thành công"); frmHienThi_DonDatHang.BaoDong = ""; this.Close(); } else { MessageBox.Show("Thất bại"); } } } else { MessageBox.Show("Không có hàng hóa trong đơn đặt hàng"); } } else { MessageBox.Show("Kiểm tra ngày"); } } catch (Exception ex) { string s = ex.Message.ToString(); MessageBox.Show("Thông tin nhập không đúng"); } }
private void SearchData(RadioButton rdoMa, RadioButton rdoNgay, RadioButton rdoTatCa, DataGridView dgv, string giatritim) { try { if (search.Length > 0) { ArrayList list = new ArrayList(); Entities.DonDatHang[] getData = null; if (rdoMa.Checked == true) { if (giatritim != "") { for (int i = 0; i < search.Length; i++) { string layma = search[i].MaDonDatHang.ToLower(); if (layma.Length > 0) { int index = layma.IndexOf(giatritim.ToLower()); if (index >= 0) { list.Add(search[i]); } } else { continue; } } int n = list.Count; if (n == 0) { getData = null; } getData = new Entities.DonDatHang[n]; for (int i = 0; i < n; i++) { getData[i] = (Entities.DonDatHang)list[i]; } dgv.DataSource = null; dgv.DataSource = getData; } else { capnhat(dgv); } } if (rdoNgay.Checked == true) { if (giatritim != "") { for (int i = 0; i < search.Length; i++) { string layma = @search[i].NgayDonHang.ToString().ToLower(); if (layma.Length > 0) { int index = layma.IndexOf(giatritim.ToLower()); if (index >= 0) { list.Add(search[i]); } } else { continue; } } int n = list.Count; if (n == 0) { getData = null; } getData = new Entities.DonDatHang[n]; for (int i = 0; i < n; i++) { getData[i] = (Entities.DonDatHang)list[i]; } dgv.DataSource = null; dgv.DataSource = getData; } else { capnhat(dgv); } } if (rdoTatca.Checked == true) { dgv.DataSource = null; dgv.DataSource = search; } } else { capnhat(dgv); } FixDataGridview(dgv); } catch (Exception ex) { string s = ex.Message; capnhat(dgv); FixDataGridview(dgv); } }
public frmXuLyDonDatHang(string hanhdong, Entities.DonDatHang dathang) { InitializeComponent(); this.hanhDong = hanhdong; this.dathang = dathang; }
/// <summary> /// do du lieu vao dgv /// </summary> private void HienThi_ChiTiet_TheoMa() { try { Entities.DonDatHang dat = new Entities.DonDatHang(); dat.Hanhdong = "Select"; dat.MaNhaCungCap = GiaTriCanLuu.Ma.ToString().ToUpper(); cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "HienThi_ChiTiet_TheoMa", dat); Entities.HienThi_ChiTiet_DonDatHang[] ddh = new Entities.HienThi_ChiTiet_DonDatHang[1]; ddh = (Entities.HienThi_ChiTiet_DonDatHang[])cl.DeserializeHepper(clientstrem, ddh); dgvXemthongtin.DataSource = ddh; new Common.Utilities().CountDatagridview(dgvXemthongtin); dgvXemthongtin.Columns[0].HeaderText = "STT"; dgvXemthongtin.RowHeadersVisible = false; dgvXemthongtin.Columns[1].HeaderText = "Mã hàng"; dgvXemthongtin.Columns[2].HeaderText = "Tên hàng"; dgvXemthongtin.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvXemthongtin.SelectionMode = DataGridViewSelectionMode.FullRowSelect; } catch (Exception) { } client.Close(); clientstrem.Close(); }
/// <summary> /// hungvv =================sua==================== /// </summary> /// <returns></returns> private Entities.DonDatHang getDatagridview() { Entities.DonDatHang dathang = new Entities.DonDatHang(); try { if (dgvHienThi.RowCount > 0) { int x = dgvHienThi.RowCount; int y = dgvHienThi.ColumnCount; if (y <= -1 || x <= -1) { } else { int vitri = dgvHienThi.CurrentRow.Index; dathang.DonDatHangID = int.Parse(dgvHienThi.Rows[vitri].Cells[1].Value.ToString()); dathang.MaDonDatHang = "" + dgvHienThi.Rows[vitri].Cells[2].Value.ToString(); dathang.LoaiDonDatHang = Convert.ToBoolean(dgvHienThi.Rows[vitri].Cells[3].Value.ToString()); dathang.NgayDonHang = Convert.ToDateTime(dgvHienThi.Rows[vitri].Cells[4].Value.ToString()); dathang.MaNhaCungCap = "" + dgvHienThi.Rows[vitri].Cells[5].Value.ToString(); dathang.NoHienThoi = dgvHienThi.Rows[vitri].Cells[6].Value.ToString(); dathang.TrangThaiDonDatHang = "" + dgvHienThi.Rows[vitri].Cells[7].Value.ToString(); dathang.NgayNhapDuKien = Convert.ToDateTime("" + dgvHienThi.Rows[vitri].Cells[8].Value.ToString()); dathang.HinhThucThanhToan = "" + dgvHienThi.Rows[vitri].Cells[9].Value.ToString(); dathang.MaKho = "" + dgvHienThi.Rows[vitri].Cells[10].Value.ToString(); dathang.MaNhanVien = "" + dgvHienThi.Rows[vitri].Cells[11].Value.ToString(); dathang.MaTienTe = "" + dgvHienThi.Rows[vitri].Cells[12].Value.ToString(); dathang.ThueGTGT = dgvHienThi.Rows[vitri].Cells[13].Value.ToString(); dathang.Phivanchuyen = dgvHienThi.Rows[vitri].Cells[14].Value.ToString(); dathang.PhiKhac = dgvHienThi.Rows[vitri].Cells[15].Value.ToString(); dathang.GhiChu = "" + dgvHienThi.Rows[vitri].Cells[16].Value.ToString(); dathang.Deleted = Boolean.Parse(dgvHienThi.Rows[vitri].Cells[17].Value.ToString()); dathang.Makhachhang = dgvHienThi.Rows[vitri].Cells[18].Value.ToString(); } } else { } } catch (Exception ex) { string s = ex.Message.ToString(); } return dathang; }
/// <summary> /// hungvv ================================================== /// </summary> private void SelectChiTietTraLaiNhaCungCap(string hanhdong) { Entities.DonDatHang pt = new Entities.DonDatHang(); pt = new Entities.DonDatHang(hanhdong); Entities.ChiTietTraLaiNhaCungCap[] pt1 = new Entities.ChiTietTraLaiNhaCungCap[10]; clientstrem = cl.SerializeObj(this.client, "ChiTietTraLaiNCC", pt); Binding((Entities.ChiTietTraLaiNhaCungCap[])cl.DeserializeHepper(clientstrem, pt1)); }
/// <summary> /// them moi, sua thong tin don dat hang /// </summary> /// <param name="hanhdong"></param> private void XuLy_DonDatHang(string hanhdong) { try { Entities.DonDatHang don = new Entities.DonDatHang(); string thoigian_1 = null; thoigian_1 = new Common.Utilities().MyDateConversion(makNgaydonhang.Text); string thoigian_2 = null; thoigian_2 = new Common.Utilities().MyDateConversion(makNgaynhapdukien.Text); if (thoigian_1 != null && thoigian_2 != null) { don.NgayDonHang = DateTime.Parse(thoigian_1); thoigian_1 = null; don.NgayNhapDuKien = DateTime.Parse(thoigian_2); thoigian_2 = null; don.Hanhdong = hanhdong; don.MaDonDatHang = "" + txtSodonhang.Text.ToUpper(); don.LoaiDonDatHang = check_loaidathang.Checked; don.MaNhaCungCap = "" + txtManhacungcap.Text.ToUpper(); don.NoHienThoi = txtNohienthoi.Text.ToString(); don.TrangThaiDonDatHang = "" + txtTrangthaidonhang.Text.ToString(); don.DieuKienThanhToan = "" + cbxDieukienthanhtoan.SelectedItem.ToString(); ; don.HinhThucThanhToan = "" + cbxHinhthucthanhtoan.SelectedItem.ToString(); don.MaKho = "" + cbxMaKho.SelectedValue.ToString().ToUpper(); don.MaNhanVien = cbxNhanvien.SelectedValue.ToString().ToUpper(); don.MaTienTe = "" + cbxTiente_Tygia.SelectedValue.ToString().ToUpper(); don.ThueGTGT = txtGiatrigiatang.Text; don.Phivanchuyen = txtPhivanchuyen.Text; don.PhiKhac = txtPhikhac.Text; don.GhiChu = "" + txtDiengiai.Text.ToString(); don.Deleted = false; if (dgvInsertOrder.RowCount > 0) { if (CheckData(don) == true) { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "DonDatHang", don); Entities.DonDatHang[] tralai = new Entities.DonDatHang[1]; int trave = Convert.ToInt32(cl.DeserializeHepper(clientstrem, tralai)); if (trave == 1) { LuuChiTietDonHang(); MessageBox.Show("Thành công"); frmHienThi_DonDatHang.BaoDong = ""; this.Close(); } else { MessageBox.Show("Thất bại"); } } } else { MessageBox.Show("Không có hàng hóa trong đơn đặt hàng");} } else { MessageBox.Show("Kiểm tra ngày"); } } catch (Exception ex) { string s = ex.Message.ToString(); MessageBox.Show("Thông tin nhập không đúng"); } }
/// <summary> /// cap nhat lai trang thai don dat hang /// </summary> private void CapNhatTrangThaiDonDatHang(string hanhdong,string MaDonDatHang,string trangthai) { if (MaDonDatHang.Length > 0) { Entities.DonDatHang dat = new Entities.DonDatHang(); dat.Hanhdong = hanhdong; dat.MaDonDatHang = MaDonDatHang; dat.TrangThaiDonDatHang = trangthai; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "CapNhatTrangThaiDonDatHang", dat); string tralai = ""; tralai = (string)cl.DeserializeHepper(clientstrem, tralai); //if (tralai == "OK") //{ MessageBox.Show("cap nhat thanh cong"); } //else //{ MessageBox.Show("Chưa thêm vào kho"); } } else { } }
/// <summary> /// xu ly don dat hang /// </summary> /// <param name="hanhdong"></param> private void XuLy_DonDatHang(string hanhdong) { try { Entities.DonDatHang don = new Entities.DonDatHang(); Common.Utilities ck = new Common.Utilities(); string thoigian_1 = makNgaydonhang.Text; string thoigian_2 = makNgaynhapdukien.Text; string thoigian_sosanh = DateServer.Date().ToString("dd/MM/yyyy"); if (ck.SoSanhNgay('/', ">=", thoigian_1, thoigian_sosanh) == true && thoigian_1 != null && thoigian_2 != null && ck.SoSanhNgay('/', ">=", thoigian_2, thoigian_sosanh) == true) { kiemtrama(check_loaidathang, txtManhacungcap.Text, txtManhacungcap.Text); bool temp = false; don.NgayDonHang = Utils.StringToDateTime(thoigian_1, out temp); //don.NgayDonHang = DateTime.Parse(new Common.Utilities().KiemTraDinhDangNgayThangNam("ThangNgayNam", thoigian_1, '/')); don.NgayNhapDuKien = Utils.StringToDateTime(thoigian_2, out temp); //don.NgayNhapDuKien = DateTime.Parse(new Common.Utilities().KiemTraDinhDangNgayThangNam("ThangNgayNam", thoigian_2, '/')); don.Hanhdong = hanhdong; don.DonDatHangID = ID; don.MaDonDatHang = "" + txtSodonhang.Text.ToUpper(); don.LoaiDonDatHang = check_loaidathang.Checked; if (check_loaidathang.Checked == true) { manhacungcap = txtManhacungcap.Text; } if (check_loaidathang.Checked == false) { manhacungcap = ""; } don.MaNhaCungCap = manhacungcap; don.NoHienThoi = txtNohienthoi.Text; don.TrangThaiDonDatHang = txtTrangthaidonhang.Text.ToString(); don.HinhThucThanhToan = cbxHinhthucthanhtoan.SelectedItem.ToString(); don.MaKho = cbxMaKho.SelectedValue.ToString().ToUpper(); don.MaNhanVien = cbxNhanvien.SelectedValue.ToString().ToUpper(); don.MaTienTe = cbxTiente_Tygia.SelectedValue.ToString().ToUpper(); don.ThueGTGT = txtGiatrigiatang.Text; don.Phivanchuyen = Double.Parse(0 + txtPhivanchuyen.Text).ToString(); don.PhiKhac = Double.Parse(0 + txtPhikhac.Text).ToString(); don.GhiChu = "" + txtDiengiai.Text.ToString(); don.Deleted = false; don.Manhanvien = Common.Utilities.User.NhanVienID; don.Tendangnhap = Common.Utilities.User.TenDangNhap; if (check_loaidathang.Checked == false) { makhachhang = txtManhacungcap.Text; } if (check_loaidathang.Checked == true) { makhachhang = ""; } don.Makhachhang = makhachhang; if (dgvInsertOrder.RowCount > 0) { if (CheckData(don) == true) { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "DonDatHang", don); Entities.DonDatHang[] tralai = new Entities.DonDatHang[1]; int trave = Convert.ToInt32(cl.DeserializeHepper(clientstrem, tralai)); if (trave == 1) { LuuChiTietDonHang(); } else { MessageBox.Show("Thất bại"); } } else { } } else { MessageBox.Show("Không có hàng hóa trong đơn đặt hàng"); } } else { MessageBox.Show("Kiểm tra ngày"); } } catch (Exception ex) { string s = ex.Message.ToString(); MessageBox.Show("Hãy kiểm tra lại thông tin nhập"); } }