Example #1
0
 private void btnTaoPhieuMoi_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult confirm = new DialogResult();
         if (dgvPhieuBeNgoan.RowCount > 0)
         {
             confirm = MessageBox.Show("Tháng này đã có dữ liệu. Bạn có chắc muốn xóa để tạo mới hoàn toàn?",
                                       "Cân nhắc", MessageBoxButtons.YesNo);
         }
         if (confirm == DialogResult.Yes || dgvPhieuBeNgoan.RowCount <= 0)
         {
             XoaPhieuCu();
             dgvPhieuBeNgoan.Columns.Clear();
             if (!string.IsNullOrEmpty(cboLop.Text))
             {
                 dgvPhieuBeNgoan.DataSource = PhieuBeNgoanBLL.TaoPhieuBeNgoanMoi(
                     LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())),
                     dtThangLapPhieu.Text);
                 TaoPhieuTrong();
                 MessageBox.Show("Một phiếu mới hoàn toàn vừa được tạo", "Thông báo");
                 btnLuuPhieu.Enabled = true;
             }
         }
         else if (confirm == DialogResult.No)
         {
             return;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Lỗi");
     }
 }
Example #2
0
        private void XoaPhieuCu()
        {
            string ngaylapphieu = dtThangLapPhieu.Text;

            for (int i = 0; i < dgvPhieuBeNgoan.Rows.Count; i++)
            {
                PhieuBeNgoanBLL.XoaPhieuBeNgoan(dgvPhieuBeNgoan.Rows[i].Cells["MaTre"].Value.ToString(),
                                                ngaylapphieu.Split('/')[0],
                                                ngaylapphieu.Split('/')[1]);
            }
        }
Example #3
0
 private void dgvPhieuBeNgoan_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         dgvPhieuBeNgoan.Rows[e.RowIndex].Cells[e.ColumnIndex].Value  = !Convert.ToBoolean(dgvPhieuBeNgoan.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
         dgvPhieuBeNgoan.Rows[e.RowIndex].Cells["cbPhieuThang"].Value = PhieuBeNgoanBLL.XetPhieuThang(dgvPhieuBeNgoan, e.RowIndex, e.ColumnIndex);
     }
     catch
     {
         return;
     }
 }
Example #4
0
        private void loadDataGridView()
        {
            dgvPhieuBeNgoan.Columns.Clear();
            if (!string.IsNullOrEmpty(cboLop.Text))
            {
                string datetime = dtThangLapPhieu.Text;
                dgvPhieuBeNgoan.DataSource = PhieuBeNgoanBLL.LayPhieuBeNgoanTheoLop(
                    LopBLL.GetInfoLop(KeyHandle.GetKeyFromCombobox(cboLop.SelectedItem.ToString())),
                    datetime);
                TaoPhieuTrong();
                if (dgvPhieuBeNgoan.RowCount <= 0)
                {
                    lbThongBao.Text     = "Tháng " + dtThangLapPhieu.Value.ToString("MM-yyyy") + " chưa tạo phiếu bé ngoan";
                    btnLuuPhieu.Enabled = false;
                    lbThongBao.Visible  = true;
                }
                else
                {
                    lbThongBao.Visible  = false;
                    btnLuuPhieu.Enabled = true;

                    for (int i = 0; i < dgvPhieuBeNgoan.Rows.Count; i++)
                    {
                        for (int j = 1; j < 5; j++)
                        {
                            DataGridViewCheckBoxCell chkBoxCell = (DataGridViewCheckBoxCell)dgvPhieuBeNgoan.Rows[i].Cells["cbPhieu" + j];
                            if (dgvPhieuBeNgoan.Rows[i].Cells["PhieuBeNgoanTuan" + j].Value.ToString() == "1")
                            {
                                chkBoxCell.Value = "true";
                            }
                            else
                            {
                                chkBoxCell.Value = "false";
                            }
                        }
                        if (dgvPhieuBeNgoan.Rows[i].Cells["PhieuBeNgoanThang"].Value.ToString() == "1")
                        {
                            dgvPhieuBeNgoan.Rows[i].Cells["cbPhieuThang"].Value = "true";
                        }
                        else
                        {
                            dgvPhieuBeNgoan.Rows[i].Cells["cbPhieuThang"].Value = "false";
                        }
                    }
                }
            }
            //(dgvPhieuBeNgoan as DataGridView).CellClick
            //                += new DataGridViewCellEventHandler(cb_CheckedChange);
        }
Example #5
0
 private void LuuPhieuBeNgoan(DataGridView dgvPhieuBeNgoan)
 {
     for (int i = 0; i < dgvPhieuBeNgoan.Rows.Count; i++)
     {
         TheoDoiThang phieubengoan = new TheoDoiThang();
         phieubengoan.MaTre = dgvPhieuBeNgoan.Rows[i].Cells["MaTre"].Value.ToString();
         string ngaylapphieu = dtThangLapPhieu.Text;
         phieubengoan.Nam          = Int32.Parse(ngaylapphieu.Split('/')[1]);
         phieubengoan.Thang        = Int32.Parse(ngaylapphieu.Split('/')[0]);
         phieubengoan.NhanXetThang = dgvPhieuBeNgoan.Rows[i].Cells["NhanXetThang"].Value.ToString();
         phieubengoan.PhieuTuan1   = Int32.Parse(dgvPhieuBeNgoan.Rows[i].Cells["PhieuBeNgoanTuan1"].Value.ToString());
         phieubengoan.PhieuTuan2   = Int32.Parse(dgvPhieuBeNgoan.Rows[i].Cells["PhieuBeNgoanTuan2"].Value.ToString());
         phieubengoan.PhieuTuan3   = Int32.Parse(dgvPhieuBeNgoan.Rows[i].Cells["PhieuBeNgoanTuan3"].Value.ToString());
         phieubengoan.PhieuTuan4   = Int32.Parse(dgvPhieuBeNgoan.Rows[i].Cells["PhieuBeNgoanTuan4"].Value.ToString());
         phieubengoan.PhieuThang   = Int32.Parse(dgvPhieuBeNgoan.Rows[i].Cells["PhieuBeNgoanThang"].Value.ToString());
         PhieuBeNgoanBLL.LuuPhieuBeNgoan(phieubengoan);
     }
 }