public void hienthi() { Server_Client.Client cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Pdck = new PhieuDieuChuyenKhoNoiBo("Select", 1, "a", DateServer.Date(), "a", "a ", "a", "a", "a", false, "a", false); clientstrem = cl.SerializeObj(this.client1, "PhieuDieuCHuyenKhoNoiBo", Pdck); PhieuDieuChuyenKhoNoiBo[] pdck1 = new PhieuDieuChuyenKhoNoiBo[1]; pdck1[0] = new PhieuDieuChuyenKhoNoiBo(1, "a", DateServer.Date(), "a", "a", "a", false, "a", false); pdck1 = (PhieuDieuChuyenKhoNoiBo[])cl.DeserializeHepper1(clientstrem, pdck1); if (pdck1 == null) { Entities.PhieuDieuChuyenKhoNoiBo[] a = new PhieuDieuChuyenKhoNoiBo[0]; PDCK_Search = a; dgvHienThi.DataSource = a; FixDataGridView(); toolStripStatus_Sua.Enabled = false; toolStripStatus_Xoa.Enabled = false; } else { PDCK_Search = pdck1; dgvHienThi.DataSource = pdck1; FixDataGridView(); toolStripStatus_Sua.Enabled = true; toolStripStatus_Xoa.Enabled = true; } }
private void toolStripStatus_Xoa_Click(object sender, EventArgs e) { if (!frmDangNhap.User.Administrator && !CheckQuyen(this.Name, 3)) { MessageBox.Show("Bạn Không có quyền vào chức năng này."); return; } if ((bool)dgvHienThi.CurrentRow.Cells["XacNhan"].Value) { MessageBox.Show("Phiếu đã xác nhận không thể xóa", "Hệ Thống cảnh báo"); return; } DialogResult dlgResult = MessageBox.Show("Bạn Có Chắc Chắn muốn Xóa không?", "Đồng ý?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlgResult == DialogResult.Yes) { try { bool ktdelete = false; int idcurent = int.Parse(dgvHienThi.CurrentRow.Cells["PhieuDieuChuyenKhoID"].Value.ToString()); hienthi(); for (int j = 0; j < PDCK_Search.Length; j++) { if (PDCK_Search[j].Deleted == false) { if (PDCK_Search[j].PhieuDieuChuyenKhoID == idcurent) { ktdelete = true; break; } } } if (ktdelete == true) { try { Server_Client.Client cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); PhieuDieuChuyenKhoNoiBo tt = new PhieuDieuChuyenKhoNoiBo("Delete", idcurent); clientstrem = cl.SerializeObj(this.client1, "PhieuDieuCHuyenKhoNoiBo", tt); //MessageBox.Show("Xoa Thanh Cong..."); } catch { } } hienthi(); } catch (Exception ex) { MessageBox.Show("Lỗi Hệ Thống- Liên Hệ nhà Quản Trị"); } } }
public void hienthi() { Server_Client.Client cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Pdck = new PhieuDieuChuyenKhoNoiBo("Select", 1, "a", DateServer.Date(), "a", "a", "a", "a", "a", false, "a", false); clientstrem = cl.SerializeObj(this.client1, "PhieuDieuCHuyenKhoNoiBo", Pdck); PhieuDieuChuyenKhoNoiBo[] pdck1 = new PhieuDieuChuyenKhoNoiBo[1]; pdck1[0] = new PhieuDieuChuyenKhoNoiBo(1, "a", DateServer.Date(), "a", "a", "a", false, "a", false); pdck1 = (PhieuDieuChuyenKhoNoiBo[])cl.DeserializeHepper1(clientstrem, pdck1); ////PDCK_Search = pdck1; if (pdck1 == null) { Entities.PhieuDieuChuyenKhoNoiBo[] a = new PhieuDieuChuyenKhoNoiBo[0]; dgvHienThi.DataSource = a; PDCK_Search = a; FixDataGridView(); toolStripStatus_Sua.Enabled = false; toolStripStatus_ChiTiet.Enabled = false; } else { int count = 0; for (int i = 0; i < pdck1.Length; i++) { if (pdck1[i].XacNhan == false) { count++; } } PhieuDieuChuyenKhoNoiBo[] pdck2 = new PhieuDieuChuyenKhoNoiBo[count]; count = 0; for (int i = 0; i < pdck1.Length; i++) { if (pdck1[i].XacNhan == false) { pdck2[count] = pdck1[i]; count++; } } PDCK_Search = pdck2; dgvHienThi.DataSource = pdck2; FixDataGridView(); toolStripStatus_Sua.Enabled = true; toolStripStatus_ChiTiet.Enabled = true; } }
private void toolStripStatus_Sua_Click(object sender, EventArgs e) { if (!frmDangNhap.User.Administrator && !CheckQuyen(this.Name, 2)) { MessageBox.Show("Bạn Không có quyền vào chức năng này."); return; } int count = 0; for (int i = 0; i < dgvHienThi.RowCount; i++) { if ((bool)dgvHienThi.Rows[i].Cells["XacNhan"].Value == true) { count++; } } PhieuDieuChuyenKhoNoiBo[] pdck = new PhieuDieuChuyenKhoNoiBo[count]; count = 0; for (int i = 0; i < dgvHienThi.RowCount; i++) { if ((bool)dgvHienThi.Rows[i].Cells["XacNhan"].Value == true) { pdck[count] = new PhieuDieuChuyenKhoNoiBo(); pdck[count].MaPhieuDieuChuyenKho = dgvHienThi.Rows[i].Cells["MaPhieuDieuChuyenKho"].Value.ToString(); pdck[count].MaHoaDonNhap = dgvHienThi.Rows[i].Cells["MaHoaDonNhap"].Value.ToString(); pdck[count].PhieuDieuChuyenKhoID = (int)dgvHienThi.Rows[i].Cells["PhieuDieuChuyenKhoID"].Value; pdck[count].NgayDieuChuyen = (DateTime)dgvHienThi.Rows[i].Cells["NgayDieuChuyen"].Value; pdck[count].TuKho = dgvHienThi.Rows[i].Cells["TuKho"].Value.ToString(); pdck[count].DenKho = dgvHienThi.Rows[i].Cells["DenKho"].Value.ToString(); pdck[count].GhiChu = dgvHienThi.Rows[i].Cells["GhiChu"].Value.ToString(); pdck[count].XacNhan = (bool)dgvHienThi.Rows[i].Cells["XacNhan"].Value; count++; } } if (pdck != null) { int i = 0; int msg = 1; while (i < pdck.Length && msg > 0) { Server_Client.Client cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.PhieuDieuChuyenKhoNoiBo nv = new Entities.PhieuDieuChuyenKhoNoiBo("Update", pdck[i].PhieuDieuChuyenKhoID, pdck[i].MaPhieuDieuChuyenKho, pdck[i].NgayDieuChuyen, pdck[i].TuKho, "", pdck[i].DenKho, "", pdck[i].MaHoaDonNhap, pdck[i].XacNhan, pdck[i].GhiChu, false); clientstrem = cl.SerializeObj(this.client1, "PhieuDieuCHuyenKhoNoiBo", nv); msg = (int)cl.DeserializeHepper(clientstrem, msg); if (pdck[i].MaHoaDonNhap.Length == 0) { dgv.DataSource = HienThiChiTietTheoPDCK(pdck[i].MaPhieuDieuChuyenKho).DataSource; int d = dgv.RowCount; CheckDataGridTruSL(dgv, pdck[i].TuKho); CheckDataGridCongSL1(dgv, pdck[i].DenKho); CheckDataGridCongSL(dgv, pdck[i].DenKho); } else if (pdck[i].MaHoaDonNhap.Length != 0) { dgv.DataSource = HienThiChiTiet(pdck[i].MaHoaDonNhap, pdck[i].MaPhieuDieuChuyenKho, pdck[i].TuKho).DataSource; CheckDataGridTruSL(dgv, pdck[i].TuKho); CheckDataGridCongSL1(dgv, pdck[i].DenKho); CheckDataGridCongSL(dgv, pdck[i].DenKho); } i++; } hienthi(); } }
private void txtTimKiem_TextChanged(object sender, EventArgs e) { if (rdbMa.Checked == true) { if (PDCK_Search == null) { PhieuDieuChuyenKhoNoiBo[] pdck = new PhieuDieuChuyenKhoNoiBo[0]; dgvHienThi.DataSource = pdck; FixDataGridView(); toolStripStatus_Sua.Enabled = false; toolStripStatus_ChiTiet.Enabled = false; } else if (PDCK_Search != null) { if (txtTimKiem.Text.Length == 0) { PhieuDieuChuyenKhoNoiBo[] pdck = new PhieuDieuChuyenKhoNoiBo[0]; dgvHienThi.DataSource = pdck; FixDataGridView(); toolStripStatus_Sua.Enabled = false; toolStripStatus_ChiTiet.Enabled = false; } else { int tt1_search_count = 0; for (int i = 0; i < PDCK_Search.Length; i++) { int index = -1; index = PDCK_Search[i].MaPhieuDieuChuyenKho.IndexOf(txtTimKiem.Text.Trim()); if (index >= 0) { tt1_search_count++; } } PhieuDieuChuyenKhoNoiBo[] tt1_search = new PhieuDieuChuyenKhoNoiBo[tt1_search_count]; tt1_search_count = 0; for (int i = 0; i < PDCK_Search.Length; i++) { int index = -1; index = PDCK_Search[i].MaPhieuDieuChuyenKho.IndexOf(txtTimKiem.Text.Trim()); if (index >= 0) { tt1_search[tt1_search_count] = PDCK_Search[i]; tt1_search_count++; } } if (tt1_search_count == 0) { toolStripStatus_Sua.Enabled = false; toolStripStatus_ChiTiet.Enabled = false; } else { toolStripStatus_Sua.Enabled = true; toolStripStatus_ChiTiet.Enabled = true; } dgvHienThi.DataSource = tt1_search; FixDataGridView(); } } } }