public void us_to_form(US_GD_LOP_MON ip_us, decimal ip_selected)
 {
     m_ma_lop = m_us.strMA_LOP_HOC;
     m_us = ip_us;
     m_txt_ma_lop.Text = m_us.strMA_LOP_HOC;
     m_dat_thoi_gian.Value = m_us.datTHOI_GIAN;
     m_txt_diem_qua_mon.Text = m_us.dcDIEM_QUA_MON.ToString();
     m_txt_dia_diem.Text = m_us.strDIA_DIEM;
     m_txt_so_luong.Text = m_us.dcSO_LUONG.ToString();
     //m_cbo_version.SelectedValue = m_us.dcID_VERSION_MON_HOC;
     //m_cbo_ma_ten_mon_hoc.SelectedValue = ip_selected;
     m_dc_id_version = m_us.dcID_VERSION_MON_HOC;
     m_dc_ma_ten_mon_hoc = ip_selected;
 }
        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();
            }
        }
 private void Update_row_change(DataRow v_data_row)
 {
     F208_gd_lop_mon_de v_f = new F208_gd_lop_mon_de();
     //var v_data_row = m_grv.GetDataRow(m_grv.GetSelectedRows()[0]);
     var v_us = new US_GD_LOP_MON(CIPConvert.ToDecimal(v_data_row["ID"].ToString()));
     US_DM_VERSION_MON_HOC us_version = new US_DM_VERSION_MON_HOC();
     DS_DM_VERSION_MON_HOC v_ds_version = new DS_DM_VERSION_MON_HOC();
     v_ds_version.EnforceConstraints = false;
     us_version.FillDataset(v_ds_version, "where ID=" + v_data_row["ID_VERSION_MON_HOC"].ToString());
     DataRow v_d_r = v_ds_version.Tables[0].Rows[0];
     decimal v_id_version = CIPConvert.ToDecimal(v_d_r[DM_VERSION_MON_HOC.ID].ToString());
     us_version = new US_DM_VERSION_MON_HOC(v_id_version);
     decimal v_index_selected = CIPConvert.ToDecimal(us_version.dcID_MON_HOC.ToString());
     v_f.Update_form(v_us, v_index_selected);
     load_data_2_grid();
 }
 private void update_lop_mon(DataRow v_dr)
 {
     US_GD_LOP_MON v_us = new US_GD_LOP_MON(CIPConvert.ToDecimal(v_dr[GD_LOP_MON.ID].ToString()));
     if (v_dr[GD_LOP_MON.DIEM_QUA_MON].ToString().Trim() != "")
     {
         v_us.dcDIEM_QUA_MON = CIPConvert.ToDecimal(v_dr[GD_LOP_MON.DIEM_QUA_MON].ToString());
     }
     if (v_dr[GD_LOP_MON.THOI_GIAN].ToString().Trim() != "")
     {
         v_us.datTHOI_GIAN = (DateTime)v_dr[GD_LOP_MON.THOI_GIAN];
     }
     if (v_dr[GD_LOP_MON.DIA_DIEM].ToString().Trim() != "")
     {
         v_us.strDIA_DIEM = v_dr[GD_LOP_MON.DIA_DIEM].ToString();
     }
     if (v_dr[GD_LOP_MON.SO_LUONG].ToString().Trim() != "")
     {
         v_us.dcSO_LUONG = CIPConvert.ToDecimal(v_dr[GD_LOP_MON.SO_LUONG].ToString());
     }
     v_us.Update();
 }
 internal void Update_form(US_GD_LOP_MON ip_us, decimal ip_selected)
 {
     us_to_form(ip_us, ip_selected);
     m_e_form_mode = DataEntryFormMode.UpdateDataState;
     this.ShowDialog();
 }
 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_search_lookup_edit.EditValue + ")");
     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 List<decimal> taoLopHoc(decimal v_so_luong_hoc_vien, decimal ip_dc_id_version_mon, decimal ip_dc_diem_qua_mon)
 {
     m_so_luong_hoc_vien = v_so_luong_hoc_vien;
     decimal v_dc_so_hoc_vien = GetSelectedRows(m_grv).Count;
     decimal v_dc_id_mon_hoc = CIPConvert.ToDecimal(m_search_lookup_edit.EditValue);
     List<decimal> v_lst_id_lop = new List<decimal>();
     var v_mon_hoc = new US_DM_MON_HOC(v_dc_id_mon_hoc);
     while (v_dc_so_hoc_vien > 0)
     {
         US_GD_LOP_MON v_us = new US_GD_LOP_MON();
         v_us.dcID_VERSION_MON_HOC = ip_dc_id_version_mon;
         v_us.dcDIEM_QUA_MON = ip_dc_diem_qua_mon;
         v_us.dcSO_LUONG = v_so_luong_hoc_vien;
         v_us.strDA_XOA = "N";
         v_us.strMA_LOP_HOC = "FAKE-" + v_mon_hoc.strMA_MON_HOC + DateTime.Now.Date.ToShortDateString() + new Random().Next(10, 99);
         v_us.strNGUOI_LAP = "admin";
         v_us.IsNGUOI_SUANull();
         v_us.Insert();
         v_lst_id_lop.Add(v_us.dcID);
         v_dc_so_hoc_vien -= CIPConvert.ToDecimal(v_so_luong_hoc_vien);
     }
     MessageBox.Show("Tạo thành công " + v_lst_id_lop.Count() + " lớp môn cho môn " + v_mon_hoc.strTEN_MON_HOC);
     return v_lst_id_lop;
 }
        private void m_cmd_assign_Click(object sender, EventArgs e)
        {
            var v_count = m_grv.SelectedRowsCount;
            if (v_count == 0)
            {
                MessageBox.Show("Vui lòng chọn nhân viên để thêm vào lớp học");

            }
            else
            {
                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_search_lookup_edit.EditValue + ")");
                if (v_ds_gd_LOP_MON.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("Chưa có lớp học nào cho môn học này. Vui lòng thêm lớp học mới!");
                }
                else
                {
                    try
                    {
                        F301_Assign v_f = new F301_Assign();
                        if (m_dc_id_lop_mon == -1)
                        {
                            m_dc_id_mon_hoc = CIPConvert.ToDecimal(m_search_lookup_edit.EditValue.ToString());
                            v_f.Display(m_dc_id_mon_hoc, ref m_dc_id_lop_mon);
                        }
                        else
                        {
                            v_f.Display(m_dc_id_lop_mon, m_dc_id_mon_hoc);
                        }
                        if (v_f.DialogResult == System.Windows.Forms.DialogResult.OK)
                        {
                            List<decimal> v_lst_id_lop = new List<decimal>();
                            v_lst_id_lop.Add(m_dc_id_lop_mon);
                            assignHV(v_lst_id_lop, GetSelectedRows(m_grv).Count);
                            MessageBox.Show("Assign thành công học viên vào lớp môn.");
                            load_data_2_grid();
                        }
                    }
                    catch (Exception v_e)
                    {
                        CSystemLog_301.ExceptionHandle(v_e);
                    }
                }
            }
        }
 private DataRow get_id_lop_mon_tu_data_row(ref decimal v_id_gdlm, DataRow v_data_row, US_DUNG_CHUNG v_us_dc)
 {
     US_GD_LOP_MON v_us_gdlm = new US_GD_LOP_MON();
     DS_GD_LOP_MON v_ds_gdlm = new DS_GD_LOP_MON();
     v_us_dc.FillDatasetWithQuery(v_ds_gdlm, "Select * from gd_lop_mon where MA_LOP_HOC='" + v_data_row["MA_LOP"].ToString() + "'");
     var v_dt_r = v_ds_gdlm.Tables[0].Rows[0];
     v_id_gdlm = CIPConvert.ToDecimal(v_dt_r["ID"].ToString());
     return v_dt_r;
 }