private void txttimkiem_TextChanged(object sender, EventArgs e) { try { if (rdbtimkiem3.Checked == true) { return; } if (txttimkiem.Text.Length == 0) { dtgvbanbuon.DataSource = new Entities.TheGiamGia[0]; return; } int soluong = 0; if (hienthi != null) { if (rdbtimkiem2.Checked == true) { for (int i = 0; i < hienthi.Length; i++) { int kiemtra = hienthi[i].MaTheGiamGia.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper()); if (kiemtra >= 0) { soluong++; } } if (soluong == 0) { dtgvbanbuon.DataSource = new Entities.TheGiamGia[0]; return; } Entities.TheGiamGia[] hienthitheoma = new Entities.TheGiamGia[soluong]; soluong = 0; for (int i = 0; i < hienthi.Length; i++) { int kiemtra = hienthi[i].MaTheGiamGia.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper()); if (kiemtra >= 0) { hienthitheoma[soluong] = hienthi[i]; soluong++; } } //Fix hiển thị foreach (Entities.TheGiamGia item in hienthitheoma) { item.GiaTriThe = new TienIch().FormatMoney(item.GiaTriThe); } ////////////////////////////////// dtgvbanbuon.DataSource = hienthitheoma; } if (soluong != 0) { } } } finally { fix(); } }
private void toolStripStatusLabel1_Click(object sender, EventArgs e) { try { if (i < 0) { MessageBox.Show("Bạn chưa chọn bản ghi", "Hệ thống cảnh báo"); return; } 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.TheGiamGia pt = new Entities.TheGiamGia(); pt.HanhDong = "Delete"; pt.MaTheGiamGia = dtgvbanbuon.Rows[i].Cells["MaTheGiamGia"].Value.ToString(); clientstrem = cl.SerializeObj(this.client1, "TheGiamGia", pt); // đổ mảng đối tượng vào datagripview int kt = 0; kt = (int)cl.DeserializeHepper(clientstrem, kt); if (kt != 0) { SelectData(); } else { MessageBox.Show("Xóa thất bại - xin thử lại sau", "Hệ thống cảnh báo"); return; } } catch { } }
void SelectData() { try { i = 0; dtgvbanbuon.RowHeadersVisible = false; 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.TheGiamGia pt = new Entities.TheGiamGia(); pt.HanhDong = "Select"; clientstrem = cl.SerializeObj(this.client1, "TheGiamGia", pt); // đổ mảng đối tượng vào datagripview hienthi = (Entities.TheGiamGia[])cl.DeserializeHepper1(clientstrem, hienthi); if (hienthi == null) { hienthi = new Entities.TheGiamGia[0]; } //Fix hiển thị foreach (Entities.TheGiamGia item in hienthi) { item.GiaTriThe = new TienIch().FormatMoney(item.GiaTriThe.Replace(",", "")); item.GiaTriConLai = new TienIch().FormatMoney(item.GiaTriConLai.Replace(",", "")); } ////////////////////////////////// dtgvbanbuon.DataSource = hienthi; if (hienthi.Length != 0) { dtgvbanbuon.Rows[0].Selected = true; } } catch { MessageBox.Show("Không kết nối được với server - thử lại sau"); dtgvbanbuon.DataSource = new Entities.TheGiamGia[0]; } finally { fix(); } }
private void tsslblthem_Click(object sender, EventArgs e) { try { if (Validate()) { if (CheckConflicInsert()) { string date, date2; try { date = new Common.Utilities().MyDateConversion(mskKetThuc.Text); } catch { MessageBox.Show("Nhập sai định dạng ngày tháng", "Hệ thông cảnh báo"); mskKetThuc.Focus(); date = ""; return; } try { date2 = new Common.Utilities().MyDateConversion(mskBatDau.Text); } catch { MessageBox.Show("Nhập sai định dạng ngày tháng", "Hệ thông cảnh báo"); mskBatDau.Focus(); date2 = ""; return; } cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.TheGiamGia pt = new Entities.TheGiamGia(); pt.HanhDong = "Insert"; pt.GiaTriThe = txtGiaTriThe.Text.Replace(",", ""); pt.MaKhachHang = txtMaKhachHang.Text; pt.MaTheGiamGia = txtMaTheGiamGia.Text; pt.NgayBatDau = DateTime.Parse(date2); pt.NgayKetThuc = DateTime.Parse(date); clientstrem = cl.SerializeObj(this.client1, "TheGiamGia", pt); int kt1 = 0; kt1 = (int)cl.DeserializeHepper(clientstrem, kt1); if (kt1 != 0) { ////Lấy Tên Khách Hàng //string tenKH = ""; //cl = new Server_Client.Client(); //this.client1 = cl.Connect(Luu.IP, Luu.Ports); //Entities.KhachHang kh = new Entities.KhachHang("Select"); //Entities.KhachHang[] kh1 = new Entities.KhachHang[0]; //clientstrem = cl.SerializeObj(this.client1, "KhachHang", kh); //kh1 = (Entities.KhachHang[])cl.DeserializeHepper1(clientstrem, kh1); //if (kh1 == null) //{ // kh1 = new Entities.KhachHang[0]; //} //foreach (Entities.KhachHang item in kh1) //{ // if (!item.Deleted && txtMaKhachHang.Text.ToUpper().Equals(item.MaKH.ToUpper())) // { // tenKH = item.Ten; // break; // } //} ////Lấy tiền tệ tỷ giá //cl = new Server_Client.Client(); //this.client1 = cl.Connect(Luu.IP, Luu.Ports); //Entities.TienTe tt1 = new Entities.TienTe(); //tt1 = new Entities.TienTe("Select"); //clientstrem = cl.SerializeObj(this.client1, "TienTe", tt1); //Entities.TienTe[] tt = new Entities.TienTe[1]; //tt = (Entities.TienTe[])cl.DeserializeHepper1(clientstrem, tt); //if (tt != null) //{ // string tentiente = tt[0].TenTienTe; //} ////Lấy khoản mục thu chi //cl = new Server_Client.Client(); //this.client1 = cl.Connect(Luu.IP, Luu.Ports); //Entities.KMThuChi KM = new Entities.KMThuChi("Select", 1, "a", "a", true, "a", "a", "a", "a", false, " "); //clientstrem = cl.SerializeObj(this.client1, "KMThuChi", KM); //Entities.KMThuChi[] tk1 = new Entities.KMThuChi[1]; //tk1[0] = new Entities.KMThuChi(1, "a", "a", true, "a", "a", "a", "a", false, ""); //tk1 = (Entities.KMThuChi[])cl.DeserializeHepper1(clientstrem, tk1); //if (tk1 == null) //{ // tk1 = new Entities.KMThuChi[0]; //} //Entities.KMThuChi KMTC = new Entities.KMThuChi(); //foreach (Entities.KMThuChi item in tk1) //{ // if (item.DoiTuong.Equals("Khach Hang") && item.LoaiKM && !item.Deleted) // { // KMTC = item; // break; // } //} ////Tạo ngầm phiếu thu //DateTime time = DateServer.Date(); //string idPTOK = ProIDPT("PhieuThu"); //string makho = new Common.Utilities().CaiDatKho("View", "", "").Giatritruyen; //cl = new Server_Client.Client(); //this.client1 = cl.Connect(Luu.IP, Luu.Ports); //Entities.PhieuThu ptOK = new Entities.PhieuThu(); //ptOK = new Entities.PhieuThu("Insert", 0, idPTOK, time, "Thu", makho, "", KMTC.TenKhoanMuc, txtMaKhachHang.Text, tenKH, Common.Utilities.User.TenNhanVien, "", "", txtGiaTriThe.Text.Replace(",",""), tt[0].MaTienTe, false, "", false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap); //clientstrem = cl.SerializeObj(this.client1, "PhieuThu", ptOK); //bool kt2 = false; //try //{ // kt2 = (bool)cl.DeserializeHepper(clientstrem, kt2); //} //catch { } ///////////////////////////////////////////// this.Close(); } else { MessageBox.Show("Thêm thất bại - xin hãy thử lại", "Hệ thống cảnh báo"); } } else { MessageBox.Show("Cập nhật Mã thẻ - Xin hãy kiểm tra lại", "Hệ thống cảnh báo"); txtMaTheGiamGia.Text = mathemoi; return; } } } catch { } }
void SelectData() { try { i = 0; dtgvbanbuon.RowHeadersVisible = false; 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.TheGiamGia pt = new Entities.TheGiamGia(); pt.HanhDong = "Select"; clientstrem = cl.SerializeObj(this.client1, "TheGiamGia", pt); // đổ mảng đối tượng vào datagripview hienthi = (Entities.TheGiamGia[])cl.DeserializeHepper1(clientstrem, hienthi); if (hienthi == null) hienthi = new Entities.TheGiamGia[0]; //Fix hiển thị foreach (Entities.TheGiamGia item in hienthi) { item.GiaTriThe = new TienIch().FormatMoney(item.GiaTriThe.Replace(",", "")); item.GiaTriConLai = new TienIch().FormatMoney(item.GiaTriConLai.Replace(",", "")); } ////////////////////////////////// dtgvbanbuon.DataSource = hienthi; if (hienthi.Length != 0) { dtgvbanbuon.Rows[0].Selected = true; } } catch { MessageBox.Show("Không kết nối được với server - thử lại sau"); dtgvbanbuon.DataSource = new Entities.TheGiamGia[0]; } finally { fix(); } }
private void tsslblthem_Click(object sender, EventArgs e) { try { if (Validate()) { if (CheckConflicInsert()) { string date, date2; try { date = new Common.Utilities().MyDateConversion(mskKetThuc.Text); } catch { MessageBox.Show("Nhập sai định dạng ngày tháng", "Hệ thông cảnh báo"); mskKetThuc.Focus(); date = ""; return; } try { date2 = new Common.Utilities().MyDateConversion(mskBatDau.Text); } catch { MessageBox.Show("Nhập sai định dạng ngày tháng", "Hệ thông cảnh báo"); mskBatDau.Focus(); date2 = ""; return; } cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.TheGiamGia pt = new Entities.TheGiamGia(); pt.HanhDong = "Insert"; pt.GiaTriThe = txtGiaTriThe.Text.Replace(",",""); pt.MaKhachHang = txtMaKhachHang.Text; pt.MaTheGiamGia = txtMaTheGiamGia.Text; pt.NgayBatDau = DateTime.Parse(date2); pt.NgayKetThuc = DateTime.Parse(date); clientstrem = cl.SerializeObj(this.client1, "TheGiamGia", pt); int kt1 = 0; kt1 = (int)cl.DeserializeHepper(clientstrem, kt1); if (kt1 != 0) { ////Lấy Tên Khách Hàng //string tenKH = ""; //cl = new Server_Client.Client(); //this.client1 = cl.Connect(Luu.IP, Luu.Ports); //Entities.KhachHang kh = new Entities.KhachHang("Select"); //Entities.KhachHang[] kh1 = new Entities.KhachHang[0]; //clientstrem = cl.SerializeObj(this.client1, "KhachHang", kh); //kh1 = (Entities.KhachHang[])cl.DeserializeHepper1(clientstrem, kh1); //if (kh1 == null) //{ // kh1 = new Entities.KhachHang[0]; //} //foreach (Entities.KhachHang item in kh1) //{ // if (!item.Deleted && txtMaKhachHang.Text.ToUpper().Equals(item.MaKH.ToUpper())) // { // tenKH = item.Ten; // break; // } //} ////Lấy tiền tệ tỷ giá //cl = new Server_Client.Client(); //this.client1 = cl.Connect(Luu.IP, Luu.Ports); //Entities.TienTe tt1 = new Entities.TienTe(); //tt1 = new Entities.TienTe("Select"); //clientstrem = cl.SerializeObj(this.client1, "TienTe", tt1); //Entities.TienTe[] tt = new Entities.TienTe[1]; //tt = (Entities.TienTe[])cl.DeserializeHepper1(clientstrem, tt); //if (tt != null) //{ // string tentiente = tt[0].TenTienTe; //} ////Lấy khoản mục thu chi //cl = new Server_Client.Client(); //this.client1 = cl.Connect(Luu.IP, Luu.Ports); //Entities.KMThuChi KM = new Entities.KMThuChi("Select", 1, "a", "a", true, "a", "a", "a", "a", false, " "); //clientstrem = cl.SerializeObj(this.client1, "KMThuChi", KM); //Entities.KMThuChi[] tk1 = new Entities.KMThuChi[1]; //tk1[0] = new Entities.KMThuChi(1, "a", "a", true, "a", "a", "a", "a", false, ""); //tk1 = (Entities.KMThuChi[])cl.DeserializeHepper1(clientstrem, tk1); //if (tk1 == null) //{ // tk1 = new Entities.KMThuChi[0]; //} //Entities.KMThuChi KMTC = new Entities.KMThuChi(); //foreach (Entities.KMThuChi item in tk1) //{ // if (item.DoiTuong.Equals("Khach Hang") && item.LoaiKM && !item.Deleted) // { // KMTC = item; // break; // } //} ////Tạo ngầm phiếu thu //DateTime time = DateServer.Date(); //string idPTOK = ProIDPT("PhieuThu"); //string makho = new Common.Utilities().CaiDatKho("View", "", "").Giatritruyen; //cl = new Server_Client.Client(); //this.client1 = cl.Connect(Luu.IP, Luu.Ports); //Entities.PhieuThu ptOK = new Entities.PhieuThu(); //ptOK = new Entities.PhieuThu("Insert", 0, idPTOK, time, "Thu", makho, "", KMTC.TenKhoanMuc, txtMaKhachHang.Text, tenKH, Common.Utilities.User.TenNhanVien, "", "", txtGiaTriThe.Text.Replace(",",""), tt[0].MaTienTe, false, "", false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap); //clientstrem = cl.SerializeObj(this.client1, "PhieuThu", ptOK); //bool kt2 = false; //try //{ // kt2 = (bool)cl.DeserializeHepper(clientstrem, kt2); //} //catch { } ///////////////////////////////////////////// this.Close(); } else { MessageBox.Show("Thêm thất bại - xin hãy thử lại", "Hệ thống cảnh báo"); } } else { MessageBox.Show("Cập nhật Mã thẻ - Xin hãy kiểm tra lại", "Hệ thống cảnh báo"); txtMaTheGiamGia.Text = mathemoi; return; } } } catch { } }