private void m_cmd_delete_Click(object sender, EventArgs e)
 {
     try
     {
          decimal v_count =CIPConvert.ToDecimal(m_grv.SelectedRowsCount.ToString());
          if (v_count == 0)
          {
              MessageBox.Show("Bạn phải chọn lớp môn để thực hiện tác vụ này!");
          }
          else
          {
              DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn muốn xóa bản ghi này không?", "Cảnh báo", MessageBoxButtons.YesNo);
              if (dialogResult == DialogResult.Yes)
              {
                  for (int i = 0; i < m_grv.SelectedRowsCount; i++)
                  {
                      var v_dr = m_grv.GetDataRow(m_grv.GetSelectedRows()[i]);
                      US_GD_DIEM v_us = new US_GD_DIEM(CIPConvert.ToDecimal(v_dr["ID"].ToString()));
                      v_us.strDA_XOA = "Y";
                      v_us.Update();
                  }
                  MessageBox.Show("Đã xóa " + m_grv.SelectedRowsCount.ToString() + " học viên.");
                  load_data_2_grid();
              }
          }
     }
     catch (Exception v_e)
     {
         CSystemLog_301.ExceptionHandle(v_e);
     }
 }
 private void m_cmd_update_Click(object sender, EventArgs e)
 {
     try
     {
         string v_da_hoc_xong = "";
         string v_da_qua_mon = "";
         decimal v_diem_chuyen_can = -1;
         decimal v_diem_giua_ky = -1;
         decimal v_diem_cuoi_ky = -1;
         F207_Nhap_diem_DE v_f = new F207_Nhap_diem_DE();
         v_f.display(ref v_da_hoc_xong, ref v_da_qua_mon, ref v_diem_chuyen_can, ref v_diem_giua_ky, ref v_diem_cuoi_ky);
         if (v_f.DialogResult == System.Windows.Forms.DialogResult.OK)
         {
             for (int i = 0; i < m_grv.SelectedRowsCount; i++)
             {
                 var v_data_row = m_grv.GetDataRow(m_grv.GetSelectedRows()[i]);
                 US_GD_DIEM v_us = new US_GD_DIEM(CIPConvert.ToDecimal(v_data_row["ID"].ToString()));
                 v_us.strQUA_MON = v_da_qua_mon;
                 v_us.strHOC_XONG_YN = v_da_hoc_xong;
                 v_us.dcDIEM_CHUYEN_CAN = v_diem_chuyen_can;
                 v_us.dcDIEM_KIEM_TRA = v_diem_giua_ky;
                 v_us.dcDIEM_THI = v_diem_cuoi_ky;
                 v_us.datNGAY_SUA = DateTime.Now.Date;
                 v_us.Update();
             }
             MessageBox.Show("Đã cập nhật thành công kết quả học cho " + m_grv.SelectedRowsCount.ToString() + " nhân viên");
             load_data_2_grid();
         }
     }
     catch (Exception v_e)
     {
         CSystemLog_301.ExceptionHandle(v_e);
     }
 }
        private void get_id_gd_diem(US_DUNG_CHUNG v_us_dc, decimal v_id_ns, decimal v_id_gdlm, DataRow v_dt_r, ref int v_int_khong_nhap_duoc, DataRow v_data_row, ref decimal v_count)
        {
            DataSet v_ds = new DataSet();
            v_ds.Tables.Add(new DataTable());
            v_us_dc.FillDatasetWithQuery(v_ds, "SELECT * FROM GD_DIEM WHERE ID_NHAN_VIEN=" + v_id_ns.ToString() + " AND ID_LOP_MON=" + v_id_gdlm.ToString());
            if (v_ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("Nhân viên này chưa có tên trong lớp môn này");

            }
            v_dt_r = v_ds.Tables[0].Rows[0];

            decimal v_id_gdd = CIPConvert.ToDecimal(v_dt_r["ID"].ToString());
            US_GD_DIEM v_us_gdd = new US_GD_DIEM(v_id_gdd);
            if (v_us_gdd.dcDIEM_CHUYEN_CAN.ToString() == "")
            {
                v_us_gdd.IsDIEM_CHUYEN_CANNull();
            }
            else
            {
                v_us_gdd.dcDIEM_CHUYEN_CAN = CIPConvert.ToDecimal(v_data_row["DIEM_CHUYEN_CAN"].ToString());
            }
            if (v_us_gdd.dcDIEM_THI.ToString() == "")
            {
                v_us_gdd.IsDIEM_THINull();
            }
            else
            {
                v_us_gdd.dcDIEM_THI = CIPConvert.ToDecimal(v_data_row["DIEM_KIEM_TRA"].ToString());
            }
            if (v_us_gdd.dcDIEM_KIEM_TRA.ToString()=="")
            {
                v_us_gdd.IsDIEM_KIEM_TRANull();
            }
            else
            {
                v_us_gdd.dcDIEM_KIEM_TRA = CIPConvert.ToDecimal(v_data_row["DIEM_THI"].ToString());
            }

            v_us_gdd.strQUA_MON = v_data_row["KET_QUA"].ToString();
            v_us_gdd.datNGAY_SUA = DateTime.Now.Date;
            v_us_gdd.strHOC_XONG_YN = "Y";
            v_us_gdd.Update();
            try
            {
                v_us_gdd.Update();
                v_data_row.Delete();

                v_count++;
            }
            catch (Exception)
            {

                MessageBox.Show("Lỗi!");
                v_int_khong_nhap_duoc++;
            }
        }
        private void assignHV(List<decimal> ip_lst_id_lop, decimal ip_so_luong_hv)
        {
            decimal v_id_lop = ip_lst_id_lop[0];
            var v_lst = GetSelectedRows(m_grv);
            for (int i = 0; i < v_lst.Count; i++)
            {
                US_GD_DIEM v_us = new US_GD_DIEM();
                var v_data_row = m_grv.GetDataRow(v_lst[i]);

                v_us.dcID_LOP_MON = ip_lst_id_lop[(int)(i / ip_so_luong_hv)];
                v_us.dcID_NHAN_VIEN = CIPConvert.ToDecimal(v_data_row[0].ToString());
                v_us.strQUA_MON = "N";
                v_us.strHOC_XONG_YN = "N";
                v_us.strDA_XOA = "N";
                v_us.datNGAY_LAP = DateTime.Now.Date;
                v_us.datNGAY_SUA = DateTime.Now.Date;
                updateNhanVienMonHoc(v_us.dcID_NHAN_VIEN);
                v_us.Insert();
            }
        }
 private void updateNhanVienMonHoc(decimal ip_dc_id_nhan_vien)
 {
     US_GD_LOP_MON v_us_gd_LOP_MON = new US_GD_LOP_MON();
     DS_GD_LOP_MON v_ds_gd_LOP_MON = new DS_GD_LOP_MON();
     v_ds_gd_LOP_MON.EnforceConstraints = false;
     v_us_gd_LOP_MON.FillDataset(v_ds_gd_LOP_MON, " WHERE ID_VERSION_MON_HOC IN (SELECT ID FROM DM_VERSION_MON_HOC WHERE ID_MON_HOC = " + m_cbo_mon_hoc.SelectedValue + ")");
     for (int i = 0; i < v_ds_gd_LOP_MON.Tables[0].Rows.Count; i++)
     {
         US_GD_DIEM v_us = new US_GD_DIEM();
         DS_GD_DIEM v_ds = new DS_GD_DIEM();
         DataRow v_dr = v_ds_gd_LOP_MON.Tables[0].Rows[i];
         v_us.FillDataset(v_ds, " where id_nhan_vien = " + ip_dc_id_nhan_vien.ToString() + " and id_lop_mon = " + v_dr[GD_LOP_MON.ID]);
         for (int j = 0; j < v_ds.Tables[0].Rows.Count; j++)
         {
             DataRow v_dr_diem = v_ds.Tables[0].Rows[j];
             decimal v_id_gd_diem = CIPConvert.ToDecimal(v_dr_diem[GD_DIEM.ID].ToString());
             v_us = new US_GD_DIEM(v_id_gd_diem);
             v_us.strDA_XOA = "Y";
             v_us.Update();
         }
     }
 }
        private void xoa_lop_mon(decimal v_count)
        {
            for (int i = 0; i < v_count; i++)
            {
                var v_data_row = m_grv.GetDataRow(m_grv.GetSelectedRows()[i]);
                US_GD_LOP_MON v_us_gd_lop_mon = new US_GD_LOP_MON(CIPConvert.ToDecimal(v_data_row["ID"].ToString()));
                decimal v_dc_id_lop_mon = CIPConvert.ToDecimal(v_us_gd_lop_mon.dcID.ToString());
                DataSet v_ds = new DataSet();
                v_ds.Tables.Add(new DataTable());
                US_DUNG_CHUNG v_us_dc = new US_DUNG_CHUNG();
                v_us_dc.FillDatasetWithQuery(v_ds, "Select * from gd_diem where id_lop_mon=" + v_dc_id_lop_mon.ToString());
                if (v_ds.Tables[0].Rows.Count > 0)
                {
                    for (int j = 0; j < v_ds.Tables[0].Rows.Count; j++)
                    {

                        var v_id_gdd = CIPConvert.ToDecimal(v_ds.Tables[0].Rows[j]["ID"].ToString());
                        var v_us_gdd= new US_GD_DIEM(v_id_gdd);
                         var v_ds_gdd = new DataSet();
                         v_ds_gdd.Tables.Add(new DataTable());
                         v_us_dc.FillDatasetWithQuery(v_ds_gdd, "Select * from gd_chung_chi where id_gd_diem=" + v_id_gdd.ToString());
                         if (v_ds_gdd.Tables[0].Rows.Count > 0)
                        {
                            var v_dtr_gdcc = v_ds_gdd.Tables[0].Rows[0];
                            var v_us_gdcc = new US_GD_CHUNG_CHI(CIPConvert.ToDecimal(v_dtr_gdcc["ID"].ToString()));
                            v_us_gdcc.strDA_XOA = "Y";
                            v_us_gdcc.Update();
                        }
                        v_us_gdd.strDA_XOA = "Y";
                        v_us_gdd.Update();
                    }
                }

                v_us_gd_lop_mon.strDA_XOA = "Y";
                v_us_gd_lop_mon.Update();
            }
        }