private void tsslThem_Click(object sender, EventArgs e) { if (Validate()) { CheckConflictInsert(); if (kt == "ok") { cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.PhongBan pb = new Entities.PhongBan("Insert", 1, txtmapb.Text, txttenpb.Text, txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap); clientstream = cl.SerializeObj(this.client1, "PhongBan", pb); int msg = 0; msg = (int)cl.DeserializeHepper(clientstream, msg); if (msg == 1) { txtmapb.Text = LayID("PhongBan"); txttenpb.Text = ""; txtghichu.Text = ""; frmQuanlyphongban.KiemTra = "insert"; this.Close(); } else { MessageBox.Show("Insert that bai"); } } } }
private void tsslSua_Click(object sender, EventArgs e) { if (Validate()) { CheckConflictUpdate(); if (kt == "ok") { cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.PhongBan pb = new Entities.PhongBan("Update", Convert.ToInt32(txtID.Text), txtmapb.Text, txttenpb.Text, txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap); clientstream = cl.SerializeObj(this.client1, "PhongBan", pb); int msg = 0; msg = (int)cl.DeserializeHepper(clientstream, msg); if (msg == 1) { this.Close(); } else { MessageBox.Show("Update that bai"); } tenphongban = txttenpb.Text; ghichu = txtghichu.Text; } else if (kt == "null") { MessageBox.Show("Bản Ghi đã bị xóa trước khi cập nhật! Vui lòng thao tác lại !"); this.Close(); } } }
public void CheckConflictUpdate() { try { 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.PhongBan pb = new Entities.PhongBan("Select"); // khởi tạo mảng đối tượng để hứng giá trị pb1 = new Entities.PhongBan[1]; clientstream = cl.SerializeObj(this.client1, "PhongBan", pb); // đổ mảng đối tượng vào datagripview pb1 = (Entities.PhongBan[])cl.DeserializeHepper1(clientstream, pb1); if (pb1 != null) { for (int j = 0; j < pb1.Length; j++) { if (pb1[j].MaPhongBan == maphongban) { kt = Check(pb1[j]); break; } else { kt = "null"; } } } } catch { } }
public void CheckConflictInsert() { try { 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.PhongBan pb = new Entities.PhongBan("Select"); // khởi tạo mảng đối tượng để hứng giá trị Entities.PhongBan[] pb1 = new Entities.PhongBan[1]; clientstream = cl.SerializeObj(this.client1, "PhongBan", pb); // đổ mảng đối tượng vào datagripview pb1 = (Entities.PhongBan[])cl.DeserializeHepper1(clientstream, pb1); if (pb1 != null) { for (int j = 0; j < pb1.Length; j++) { if (pb1[j].MaPhongBan == txtmapb.Text) { MessageBox.Show("cập nhật mã Khoản Mục - kiểm tra lại để insert"); kt = "ko"; txtmapb.Text = LayID("PhongBan"); break; } else { kt = "ok"; } } } else { kt = "ok"; } } catch { } }
public string Check(Entities.PhongBan pb) { string gt = "ok"; if (tenphongban != pb.TenPhongBan) { tenphongban = txttenpb.Text = pb.TenPhongBan; gt = "ko"; } if (ghichu != pb.GhiChu) { ghichu = txtghichu.Text = pb.GhiChu; gt = "ko"; } if (gt == "ko") { MessageBox.Show("Dữ liệu đã có thay đổi trước, ấn ok để cập nhật lại."); } return(gt); }
public void CheckConflictInsert() { try { 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.PhongBan pb = new Entities.PhongBan("Select"); // khởi tạo mảng đối tượng để hứng giá trị Entities.PhongBan[] pb1 = new Entities.PhongBan[1]; clientstream = cl.SerializeObj(this.client1, "PhongBan", pb); // đổ mảng đối tượng vào datagripview pb1 = (Entities.PhongBan[])cl.DeserializeHepper1(clientstream, pb1); if (pb1 != null) { for (int j = 0; j < pb1.Length; j++) { if (pb1[j].MaPhongBan == txtmapb.Text) { MessageBox.Show("cập nhật mã Khoản Mục - kiểm tra lại để insert"); kt = "ko"; txtmapb.Text = LayID("PhongBan"); break; } else kt = "ok"; } } else kt = "ok"; } catch { } }
private void tsslThem_Click(object sender, EventArgs e) { if (Validate()) { CheckConflictInsert(); if (kt == "ok") { cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.PhongBan pb = new Entities.PhongBan("Insert", 1, txtmapb.Text, txttenpb.Text, txtghichu.Text, false,Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap); clientstream = cl.SerializeObj(this.client1, "PhongBan", pb); int msg = 0; msg = (int)cl.DeserializeHepper(clientstream, msg); if (msg == 1) { txtmapb.Text = LayID("PhongBan"); txttenpb.Text = ""; txtghichu.Text = ""; frmQuanlyphongban.KiemTra = "insert"; this.Close(); } else MessageBox.Show("Insert that bai"); } } }
private void tsslSua_Click(object sender, EventArgs e) { if (Validate()) { CheckConflictUpdate(); if (kt == "ok") { cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.PhongBan pb = new Entities.PhongBan("Update", Convert.ToInt32(txtID.Text), txtmapb.Text, txttenpb.Text, txtghichu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap); clientstream = cl.SerializeObj(this.client1, "PhongBan", pb); int msg = 0; msg = (int)cl.DeserializeHepper(clientstream, msg); if (msg == 1) { this.Close(); } else MessageBox.Show("Update that bai"); tenphongban = txttenpb.Text; ghichu = txtghichu.Text; } else if (kt=="null") { MessageBox.Show("Bản Ghi đã bị xóa trước khi cập nhật! Vui lòng thao tác lại !"); this.Close(); } } }
public void CheckConflictUpdate() { try { 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.PhongBan pb = new Entities.PhongBan("Select"); // khởi tạo mảng đối tượng để hứng giá trị pb1 = new Entities.PhongBan[1]; clientstream = cl.SerializeObj(this.client1, "PhongBan", pb); // đổ mảng đối tượng vào datagripview pb1 = (Entities.PhongBan[])cl.DeserializeHepper1(clientstream, pb1); if (pb1 != null) { for (int j = 0; j < pb1.Length; j++) { if (pb1[j].MaPhongBan == maphongban) { kt = Check(pb1[j]); break; } else kt = "null"; } } } catch { } }