Inheritance: IP.Core.IPUserService.US_Object
 private void load_data_to_grid()
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
     DataTable v_dt= v_us.FillDatasetBCTangGiamLD( m_dat_tu_ngay.DateTime, m_dat_den_ngay.DateTime).Tables[0];
     m_tree_list.ParentFieldName = DM_DON_VI.ID_DON_VI_CAP_TREN;
     m_tree_list.DataSource = v_dt;
     m_tree_list.ExpandAll();
 }
 private bool check_loai_hd_dang_su_dung(decimal ip_id_loai_hd)
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
     DS_GD_HOP_DONG v_ds = new DS_GD_HOP_DONG();
     v_us.FillDataset(v_ds, "where id_loai_hop_dong =" + ip_id_loai_hd);
     if (v_ds.Tables[0].Rows.Count == 0)
         return false;
     return true;
 }
 private void load_data_to_grid()
 {
     decimal v_id_don_vi = Convert.ToDecimal((m_tree_don_vi.FocusedNode.GetValue("ID")));
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
     DataSet v_ds = new DataSet();
     v_ds.Tables.Add(new DataTable());
     v_us.FillDatasetHopDong(v_ds,v_id_don_vi);
     m_grc.DataSource = v_ds.Tables[0];
 }
 internal void display_for_update(DataRow v_dr)
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG(CIPConvert.ToDecimal(v_dr[GD_HOP_DONG.ID]));
     m_us_gd_hd = v_us;
     m_e_form_mode = DataEntryFormMode.UpdateDataState;
     us_to_form(v_dr);
     m_sle_chon_nhan_vien.Enabled = false;
     this.ShowDialog();
 }
 private bool check_hd_dang_su_dung(decimal ip_id_chuc_vu)
 {
     US_GD_HOP_DONG v_us_hd = new US_GD_HOP_DONG();
     DS_GD_HOP_DONG v_ds_hd = new DS_GD_HOP_DONG();
     v_us_hd.FillDataset(v_ds_hd, "where id_chuc_vu =" + ip_id_chuc_vu);
     if (v_ds_hd.Tables[0].Rows.Count == 0)
     {
         return false;
     }
     else return true;
 }
 public void display_for_update(DataRow v_dr)
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG(CIPConvert.ToDecimal(v_dr[GD_HOP_DONG.ID]));
     m_us_gd_hd = v_us;
     layoutControlGroup5.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
     m_sle_ma_lns.Enabled = false;
     m_sle_muc_lns.Enabled = false;
     m_txt_he_so_lns.Enabled = false;
     m_sle_chon_nhan_vien.Enabled = false;
     m_sle_loai_hop_dong.Enabled = false;
     m_txt_ma_hd.Enabled = false;
     m_sle_loai_lao_dong.Enabled = false;
     m_sle_don_vi.Enabled = false;
     m_sle_chuc_vu.Enabled = false;
     m_e_form_mode = DataEntryFormMode.UpdateDataState;
     us_to_form(v_dr);
     m_sle_chon_nhan_vien.Enabled = false;
     this.ShowDialog();
 }
        private decimal find_id_hop_by_ma_hop_dong(string ip_str_ma_nv)
        {
            US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
            DS_GD_HOP_DONG v_ds = new DS_GD_HOP_DONG();

            v_us.FillDataset(v_ds);

            string v_str_filter = "MA_HOP_DONG = '" + ip_str_ma_nv + "'";
            DataRow[] v_dr = v_ds.GD_HOP_DONG.Select(v_str_filter);

            if (v_dr.Count() == 0)
            {
                return -1;
            }
            else
            {
                return CIPConvert.ToDecimal(v_dr.First()["ID"].ToString());
            }
        }
 //Get data
 private DataTable get_danh_sach_hop_dong_con_hieu_luc()
 {
     US_GD_HOP_DONG v_us_hd = new US_GD_HOP_DONG();
     return v_us_hd.LayDanhSachHopDongConHieuLuc();
 }
        private void setup_for_update_lns(decimal ip_dc_id_gd_he_so_lns)
        {
            m_e_loai_form = e_loai_form.UPDATE_LNS;
            US_GD_HE_SO_LNS v_us_hs_lns = new US_GD_HE_SO_LNS(ip_dc_id_gd_he_so_lns);
            US_GD_HS_LNS_LCD v_us_hs_lns_lcd = new US_GD_HS_LNS_LCD();//new US_GD_HS_LNS_LCD(v_us_hs_lns.dcID_HS_LNS_LCD);

            m_us_save.dcID = ip_dc_id_gd_he_so_lns;

            m_sle_hop_dong.EditValue = v_us_hs_lns_lcd.dcID_HOP_DONG;
            m_txt_gia_tri_thay_doi.EditValue = v_us_hs_lns.dcHE_SO;
            m_dat_tu_ngay.DateTime = v_us_hs_lns.datNGAY_BAT_DAU;
            m_dat_den_ngay.DateTime = v_us_hs_lns.datNGAY_KET_THUC;
            //m_le_ly_do_chinh_sua.EditValue = v_us_hs_lns.dcID_LY_DO_CHINH_SUA;
            m_txt_ghi_chu.Text = v_us_hs_lns.strGHI_CHU;
            Text = "F391 - Cập nhật chỉnh sửa hệ số LNS";

            US_GD_HOP_DONG v_us_hd = new US_GD_HOP_DONG();
            decimal op_he_so = 0;
            string op_ma = "";
            string op_muc = "";
            v_us_hd.LayMaMucLNSCuaHopDong(Convert.ToDecimal(m_sle_hop_dong.EditValue), out op_he_so, out op_ma, out op_muc);
            m_txt_ma.Text = op_ma;
            m_txt_muc.Text = op_muc;
            m_txt_gia_tri_ma_muc.EditValue = op_he_so;

            m_sle_hop_dong.ReadOnly = true;
        }
 private DataTable load_data_to_ma_hd()
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
     DS_GD_HOP_DONG v_ds_hd = new DS_GD_HOP_DONG();
     v_us.FillDataset(v_ds_hd);
     return v_ds_hd.Tables[0];
 }
        private void save_data()
        {
            US_GD_HOP_DONG v_us_gd_hd = new US_GD_HOP_DONG();
            US_GD_CONG_TAC v_us_gd_cong_tac = new US_GD_CONG_TAC();
            US_GD_HE_SO_LNS v_us_gd_hs_lns = new US_GD_HE_SO_LNS();
            try
            {
                for (int i = 0; i < m_grv_hop_dong.RowCount; i++)
                {
                    var data = m_grv_hop_dong.GetDataRow(i);
                    //
                    grid_to_us_gd_hop_dong(v_us_gd_hd, data);
                    grid_to_us_gd_cong_tac(v_us_gd_cong_tac, data);
                    grid_to_us_gd_lns(v_us_gd_hs_lns, data);

                    //decimal v_id_hop_dong = get_id_hop_dong_hien_tai(v_us_gd_hd.dcID_NHAN_VIEN.ToString());

                    //
                    v_us_gd_hd.BeginTransaction();
                    //if (v_id_hop_dong != 0)
                    //{
                    //    ket_thuc_hop_dong_cu(v_id_hop_dong, v_us_gd_hd.datNGAY_BAT_DAU);
                    //}
                    v_us_gd_cong_tac.UseTransOfUSObject(v_us_gd_hd);
                    //v_us_gd_cong_tac.CapNhatHetHieuLucCongTac(v_us_gd_hd.dcID_NHAN_VIEN, v_us_gd_hd.datNGAY_BAT_DAU);
                    v_us_gd_hs_lns.UseTransOfUSObject(v_us_gd_hd);
                    //v_us_gd_hs_lns.KetThucLuongNangSuatNhanVien(v_us_gd_hd.dcID_NHAN_VIEN, v_us_gd_hd.datNGAY_BAT_DAU);
                    v_us_gd_hs_lns.Insert();
                    v_us_gd_hd.Insert();
                    v_us_gd_cong_tac.Insert();
                    v_us_gd_hd.CommitTransaction();
                }
                CHRM_BaseMessages.MsgBox_Infor("Đã lưu dữu liệu thành công");
            }
            catch (Exception)
            {
                if (v_us_gd_hd.is_having_transaction())
                {
                    v_us_gd_hd.Rollback();
                }
                throw;
            }
        }
 private void ket_thuc_hop_dong_cu(decimal ip_id_hop_dong)
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG(ip_id_hop_dong);
     v_us.datNGAY_KET_THUC = m_dat_ngay_bat_dau.DateTime.Date;
     v_us.Update();
 }
 private void cho_hop_dong_da_co_ve_trang_thai_delete_Y()
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG(m_id_gd_hd);
     v_us.datNGAY_SUA = DateTime.Now.Date;
     //nguoi sua
     v_us.BeginTransaction();
     v_us.Update();
     v_us.CommitTransaction();
 }
        //Insert, update, delete
        private decimal find_id_hd(decimal ip_dc_id_nv)
        {
            US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
            DS_GD_HOP_DONG v_ds = new DS_GD_HOP_DONG();

            v_us.FillDataset(v_ds);

            string v_str_filter = "ID_NHAN_VIEN = " + ip_dc_id_nv + " AND DA_XOA = 'N'";
            DataRow[] v_dr = v_ds.GD_HOP_DONG.Select(v_str_filter);

            if (v_dr.Count() == 0)
            {
                return -1;
            }
            else
            {
                return CIPConvert.ToDecimal(v_dr.First()["ID"].ToString());
            }
        }
 private bool check_ma_hd_da_ton_tai(string ip_str_ma_hd)
 {
     if (m_us_gd_hd.strMA_HOP_DONG != ip_str_ma_hd)
     {
         US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
         DS_GD_HOP_DONG v_ds = new DS_GD_HOP_DONG();
         v_us.FillDataset(v_ds, "where MA_HOP_DONG = '" + ip_str_ma_hd + "'");
         if (v_ds.Tables[0].Rows.Count != 0)
             return true;
     }
     return false;
 }
 private void load_data_to_grid()
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
     DataSet v_ds = new DataSet();
     v_ds.Tables.Add(new DataTable());
     //m_grc.DataSource = v_us.LayDanhSachHopDong(get_option_filter(), );
 }
 void m_cmd_delete_Click(object sender, EventArgs e)
 {
     try
     {
         int[] v_selected_row = m_grv.GetSelectedRows();
         if(v_selected_row.Length > 1)
         {
             XtraMessageBox.Show("Bạn chỉ được chọn 1 dòng để xóa!", "Xác nhận", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             return;
         }
         int v_focused_row = m_grv.FocusedRowHandle;
         if (v_focused_row >= 0)
         {
             string v_str_confirm = "Bạn có chắc chắn muốn xóa hợp đồng này?\nViệc xóa hợp đồng chỉ nên thực hiện khi bạn cập nhật sai.\nViệc xóa hợp đồng có thể ảnh hưởng tới các dữ liệu tiền lương đã tính trước đó!";
             DialogResult v_dialog = XtraMessageBox.Show(v_str_confirm, "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);
             if (v_dialog == DialogResult.Yes)
             {
                 decimal v_id_hop_dong = Convert.ToDecimal(m_grv.GetRowCellValue(v_focused_row, "ID"));
                 //delete_gd_he_so_lns(v_id_hop_dong);
                 //delete_gd_lcd(v_id_hop_dong);
                 US_GD_HOP_DONG v_us = new US_GD_HOP_DONG(v_id_hop_dong);
                 v_us.Delete();
                 XtraMessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 load_data_to_grid();
             }
         }
         else
         {
             string v_str_error = "Bạn chưa chọn hợp đồng để xóa!";
             XtraMessageBox.Show(v_str_error, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception v_e)
     {
         CSystemLog_301.ExceptionHandle(v_e);
     }
 }
        private decimal find_id_loai_hop_dong_cua_nhan_vien(decimal ip_dc_id_gd_hd)
        {
            US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
            DS_GD_HOP_DONG v_ds = new DS_GD_HOP_DONG();

            v_us.FillDataset(v_ds);

            string v_str_filter = "ID = " + ip_dc_id_gd_hd + " AND DA_XOA = 'N'";
            DataRow[] v_dr = v_ds.GD_HOP_DONG.Select(v_str_filter);

            if (v_dr.Count() == 0)
            {
                return -1;
            }
            else
            {
                return CIPConvert.ToDecimal(v_dr.First()["ID_LOAI_HOP_DONG"].ToString());
            }
        }
        private void us_obj_2_form(decimal v_id_gd_hd, decimal v_id_gd_lns_lcd)
        {
            US_GD_HOP_DONG v_us_gd_hd = new US_GD_HOP_DONG(v_id_gd_hd);

            if (v_id_gd_lns_lcd != -1)
            {
                US_GD_HS_LNS_LCD v_us_gd_lns_lcd = new US_GD_HS_LNS_LCD(v_id_gd_lns_lcd);
                US_DM_HE_SO_LUONG_NS v_us_dm_hs_lns = new US_DM_HE_SO_LUONG_NS(v_us_gd_lns_lcd.dcID_HS_LNS);
                US_DM_LUONG_CHE_DO v_us_dm_lcd = new US_DM_LUONG_CHE_DO(v_us_gd_lns_lcd.dcID_LCD);
                m_sle_chon_nhan_vien.EditValue = v_us_gd_hd.dcID_NHAN_VIEN;
                m_txt_ma_hd.Text = v_us_gd_hd.strMA_HOP_DONG;
                m_sle_loai_hop_dong.EditValue = v_us_gd_hd.dcID_LOAI_HOP_DONG;
                m_dat_ngay_bat_dau.Value = v_us_gd_hd.datNGAY_BAT_DAU;
                m_dat_ngay_ket_thuc.Value = v_us_gd_hd.datNGAY_KET_THUC;
                m_dat_ngay_ky.Value = v_us_gd_hd.datNGAY_KY_HOP_DONG;

                if (v_us_gd_hd.dcID_LOAI_HOP_DONG == CONST_ID_LOAI_HOP_DONG.HOP_DONG_HOC_VIEC)
                {
                    m_gr_LNS.Enabled = false;
                    m_gr_LCD.Enabled = false;
                }
                else
                {
                    m_sle_chuc_danh_lns.EditValue = v_us_dm_hs_lns.dcID_MA_LNS;
                    m_sle_muc_lns.EditValue = v_us_dm_hs_lns.dcID_MUC_LNS;
                    m_sle_chuc_danh_lcd.EditValue = v_us_dm_lcd.dcID_MA_LCD;
                    m_sle_muc_lcd.EditValue = v_us_dm_lcd.dcID_MUC_LCD;
                }
            }
            else
            {
                m_sle_chon_nhan_vien.EditValue = v_us_gd_hd.dcID_NHAN_VIEN;
                m_txt_ma_hd.Text = v_us_gd_hd.strMA_HOP_DONG;
                m_sle_loai_hop_dong.EditValue = v_us_gd_hd.dcID_LOAI_HOP_DONG;
                m_dat_ngay_bat_dau.Value = v_us_gd_hd.datNGAY_BAT_DAU;
                m_dat_ngay_ket_thuc.Value = v_us_gd_hd.datNGAY_KET_THUC;
                m_dat_ngay_ky.Value = v_us_gd_hd.datNGAY_KY_HOP_DONG;
                if (v_us_gd_hd.dcID_LOAI_HOP_DONG == CONST_ID_LOAI_HOP_DONG.HOP_DONG_HOC_VIEC)
                {
                    m_gr_LNS.Enabled = false;
                    m_gr_LCD.Enabled = false;
                }
            }

            if (m_e_form_mode == DataEntryFormMode.UpdateDataState)
            {

            }
        }
        //Insert, update, delete
        private void form_2_us_gd_hop_dong(US_GD_HOP_DONG ip_us)
        {
            try
            {
                ip_us.dcID_NHAN_VIEN = CIPConvert.ToDecimal(m_sle_chon_nhan_vien.EditValue);
                ip_us.dcID_LOAI_HOP_DONG = CIPConvert.ToDecimal(m_sle_loai_hop_dong.EditValue);
                ip_us.strMA_HOP_DONG = m_txt_ma_hd.Text.Trim();
                ip_us.datNGAY_BAT_DAU = m_dat_ngay_bat_dau.Value.Date;
                if (m_dat_ngay_ket_thuc.Checked == true)
                {
                    ip_us.datNGAY_KET_THUC = m_dat_ngay_ket_thuc.Value.Date;
                }
                ip_us.datNGAY_KY_HOP_DONG = m_dat_ngay_ky.Value.Date;
                if (m_e_form_mode == DataEntryFormMode.InsertDataState)
                {
                    ip_us.datNGAY_LAP = DateTime.Now.Date;
                    //Nguoi lap
                    ip_us.strNGUOI_LAP = CAppContext_201.getCurrentUserName();
                }
                if (m_e_form_mode == DataEntryFormMode.UpdateDataState)
                {
                    ip_us.datNGAY_SUA = DateTime.Now.Date;
                    //nguoi sua
                    ip_us.strNGUOI_SUA = CAppContext_201.getCurrentUserName();
                }

            }
            catch (Exception v_e)
            {
                throw v_e;
            }
        }
 //Fill Data TO Control
 private void fill_data_to_control_insert_lns()
 {
     US_GD_HOP_DONG v_us_hd = new US_GD_HOP_DONG();
     decimal op_he_so = 0;
     string op_ma = "";
     string op_muc = "";
     v_us_hd.LayMaMucLNSCuaHopDong(Convert.ToDecimal(m_sle_hop_dong.EditValue), out op_he_so, out op_ma, out op_muc);
     m_txt_ma.Text = op_ma;
     m_txt_muc.Text = op_muc;
     m_txt_gia_tri_ma_muc.EditValue = op_he_so;
 }
        private void save_data()
        {
            US_GD_HS_LNS_LCD v_us_gd_hs_lns_lcd = new US_GD_HS_LNS_LCD();
            US_GD_HE_SO_LNS v_us_gd_hs_lns = new US_GD_HE_SO_LNS();
            US_GD_LUONG_CHE_DO v_us_gd_lcd = new US_GD_LUONG_CHE_DO();
            US_GD_TRANG_THAI_LAO_DONG v_us_gd_trang_thai_lao_dong = new US_GD_TRANG_THAI_LAO_DONG();
            US_GD_HOP_DONG v_us_gd_hd = new US_GD_HOP_DONG();
            form_2_us_gd_hop_dong(v_us_gd_hd);
            US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
            switch (m_e_form_mode)
            {
                case DataEntryFormMode.UpdateDataState:
                    v_us_gd_hd.BeginTransaction();
                    v_us_gd_hd.dcID = CIPConvert.ToDecimal(m_grv_lap_hd.GetRowCellValue(m_grv_lap_hd.FocusedRowHandle, "ID"));
                    v_us_gd_hd.Update();
                    v_us_gd_hd.CommitTransaction();

                    //
                    form_2_us_gd_hs_lns_lcd(v_us_gd_hs_lns_lcd);
                    v_us_gd_hs_lns_lcd.BeginTransaction();
                    v_us_gd_hs_lns_lcd.dcID = find_id_gd_lns_lcd(CIPConvert.ToDecimal(m_grv_lap_hd.GetRowCellValue(m_grv_lap_hd.FocusedRowHandle, "ID")));
                    v_us_gd_hs_lns_lcd.Update();
                    v_us_gd_hs_lns_lcd.CommitTransaction();
                    break;
                case DataEntryFormMode.InsertDataState:
                    v_us.lap_hop_dong_moi_cho_nhan_vien(CIPConvert.ToDecimal(m_sle_chon_nhan_vien.EditValue)
                                                        , CIPConvert.ToDecimal(m_sle_loai_hop_dong.EditValue)
                                                        , m_txt_ma_hd.Text.Trim()
                                                        , m_dat_ngay_bat_dau.Value.Date
                                                        , m_dat_ngay_ket_thuc.Value.Date
                                                        , m_dat_ngay_ky.Value.Date
                                                        , DateTime.Now.Date
                                                        , CAppContext_201.getCurrentUserName()
                                                        , "N"
                                                        , CIPConvert.ToDecimal(m_sle_chuc_danh_lcd.EditValue)
                                                        , CIPConvert.ToDecimal(m_sle_muc_lcd.EditValue)
                                                        , CIPConvert.ToDecimal(m_sle_chuc_danh_lns.EditValue)
                                                        , CIPConvert.ToDecimal(m_sle_muc_lns.EditValue)
                                                        , ref op_str_mess);
                    break;
                case DataEntryFormMode.ViewDataState:
                    break;
                case DataEntryFormMode.SelectDataState:
                    break;
                default:
                    break;
            }

            //US_GD_HS_LNS_LCD v_us_gd_hs_lns_lcd = new US_GD_HS_LNS_LCD();
            //US_GD_HE_SO_LNS v_us_gd_hs_lns = new US_GD_HE_SO_LNS();
            //US_GD_LUONG_CHE_DO v_us_gd_lcd = new US_GD_LUONG_CHE_DO();
            //US_GD_TRANG_THAI_LAO_DONG v_us_gd_trang_thai_lao_dong = new US_GD_TRANG_THAI_LAO_DONG();
            //US_GD_HOP_DONG v_us_gd_hd = new US_GD_HOP_DONG();
            //form_2_us_gd_hop_dong(v_us_gd_hd);
            //try
            //{
            //    switch (m_e_form_mode)
            //    {
            //        case DataEntryFormMode.InsertDataState:
            //            if (m_id_gd_hd != -1)
            //            {
            //                cho_hop_dong_da_co_ve_trang_thai_delete_Y();
            //                cho_gd_hs_lns_lcd_da_xoa_Y();
            //                cho_gd_hs_lns_da_xoa_Y();
            //                cho_gd_lcd_da_xoa_Y();
            //            }

            //            //lap hop dong moi
            //            v_us_gd_hd.BeginTransaction();
            //            v_us_gd_hd.Insert();
            //            v_us_gd_hd.CommitTransaction();

            //            //insert gd_hs_lns_lcd
            //            form_2_us_gd_hs_lns_lcd(v_us_gd_hs_lns_lcd);
            //            v_us_gd_hs_lns_lcd.BeginTransaction();
            //            v_us_gd_hs_lns_lcd.Insert();
            //            v_us_gd_hs_lns_lcd.CommitTransaction();

            //            //insert gd_hs_lns
            //            form_2_us_gd_hs_lns(v_us_gd_hs_lns);
            //            v_us_gd_hs_lns.BeginTransaction();
            //            v_us_gd_hs_lns.Insert();
            //            v_us_gd_hs_lns.CommitTransaction();

            //            //insert gd_lcd
            //            form_2_us_gd_lcd(v_us_gd_lcd);
            //            v_us_gd_lcd.BeginTransaction();
            //            v_us_gd_lcd.Insert();
            //            v_us_gd_lcd.CommitTransaction();

            //            //insert gd_trang_thai_ld
            //            decimal v_id_gd_trang_thai_lao_dong_da_co = 0;

            //            v_id_gd_trang_thai_lao_dong_da_co = find_id_trang_thai_lao_dong_da_co(decimal.Parse(m_sle_chon_nhan_vien.EditValue.ToString())); //sai o day

            //            if (v_id_gd_trang_thai_lao_dong_da_co == -1)
            //            {
            //                form_2_us_gd_trang_thai_lao_dong(v_us_gd_trang_thai_lao_dong);
            //                v_us_gd_trang_thai_lao_dong.BeginTransaction();
            //                v_us_gd_trang_thai_lao_dong.Insert();
            //                v_us_gd_trang_thai_lao_dong.CommitTransaction();
            //            }
            //            break;
            //        case DataEntryFormMode.UpdateDataState:
            //            v_us_gd_hd.BeginTransaction();
            //            v_us_gd_hd.dcID = CIPConvert.ToDecimal(m_grv_lap_hd.GetRowCellValue(m_grv_lap_hd.FocusedRowHandle, "ID"));
            //            v_us_gd_hd.Update();
            //            v_us_gd_hd.CommitTransaction();

            //            //
            //            form_2_us_gd_hs_lns_lcd(v_us_gd_hs_lns_lcd);
            //            v_us_gd_hs_lns_lcd.BeginTransaction();
            //            v_us_gd_hs_lns_lcd.dcID = find_id_gd_lns_lcd(CIPConvert.ToDecimal(m_grv_lap_hd.GetRowCellValue(m_grv_lap_hd.FocusedRowHandle, "ID")));
            //            v_us_gd_hs_lns_lcd.Update();
            //            v_us_gd_hs_lns_lcd.CommitTransaction();
            //            break;
            //        default:
            //            break;
            //    }
            //}
            //catch (Exception v_e)
            //{

            //    throw v_e;
            //}
        }
 private void load_data_to_grid(DateTime ip_date_tai_ngay)
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
     m_data_set = v_us.ThongKeNhanVienTaiNgay(m_date);
     m_grc.DataSource = m_data_set.Tables[0];
     m_grv.BestFitColumns();
 }
 private void insert_data(DataRow dataRow)
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
     if(checked_du_lieu_is_ok(dataRow))
     {
         v_us.lap_hop_dong_moi_cho_nhan_vien(find_id_nhan_vien_by_ma_nv(dataRow["MA_NHAN_VIEN"].ToString().Trim())
             , CIPConvert.ToDecimal(dataRow["LOAI_HOP_DONG"].ToString())
             , dataRow["MA_HOP_DONG"].ToString()
             , WinFormControls.FormatPostingDate(dataRow["NGAY_BAT_DAU"].ToString())
             , WinFormControls.FormatPostingDate(dataRow["NGAY_KET_THUC"].ToString())
             , WinFormControls.FormatPostingDate(dataRow["NGAY_KI_HOP_DONG"].ToString())
             //, DateTime.FromOADate(Convert.ToDouble(dataRow["NGAY_BAT_DAU"]))
             //, DateTime.FromOADate(Convert.ToDouble(dataRow["NGAY_KET_THUC"]))
             //, DateTime.FromOADate(Convert.ToDouble(dataRow["NGAY_KI_HOP_DONG"]))
             , DateTime.Now.Date
             , CAppContext_201.getCurrentUserName()
             , "N"
             , CIPConvert.ToDecimal(dataRow["CHUC_DANH_LCD"].ToString())
             , CIPConvert.ToDecimal(dataRow["MUC_LCD"].ToString())
             , CIPConvert.ToDecimal(dataRow["CHUC_DANH_LNS"].ToString())
             , CIPConvert.ToDecimal(dataRow["MUC_LUONG_NS"].ToString())
             , ref op_str_mess
             );
     }
     else
     {
         CHRM_BaseMessages.MsgBox_Error("Kiểm tra lại dữ liệu!");
     }
 }
 private decimal get_id_hop_dong_hien_tai(string ip_id_nv)
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
     return v_us.GetHopDongHienTaiCuaNV(ip_id_nv);
 }
 private void ket_thuc_hop_dong_cu(decimal ip_id_hop_dong, DateTime ip_dat_ngay_ket_thuc)
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG(ip_id_hop_dong);
     v_us.datNGAY_KET_THUC = ip_dat_ngay_ket_thuc;
     v_us.Update();
 }
 private void gan_du_lieu_cho_us_gd_hop_dong(DataRow dataRow)
 {
     US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();
     v_us.dcID_LOAI_HOP_DONG = CIPConvert.ToDecimal(dataRow["LOAI_HOP_DONG"].ToString());
     if (dataRow["NGAY_BAT_DAU"].ToString() != "")
         if ((dataRow["NGAY_BAT_DAU"].ToString() != ""))
             v_us.datNGAY_BAT_DAU = DateTime.FromOADate(Convert.ToDouble(dataRow["NGAY_BAT_DAU"]));
     if (dataRow["NGAY_KET_THUC"].ToString() != "")
         if ((dataRow["NGAY_KET_THUC"].ToString() != ""))
             v_us.datNGAY_KET_THUC = DateTime.FromOADate(Convert.ToDouble(dataRow["NGAY_KET_THUC"]));
     if (dataRow["NGAY_KI_HOP_DONG"].ToString() != "")
         if ((dataRow["NGAY_KI_HOP_DONG"].ToString() != ""))
             v_us.datNGAY_KY_HOP_DONG = DateTime.FromOADate(Convert.ToDouble(dataRow["NGAY_KI_HOP_DONG"]));
     v_us.dcID_NHAN_VIEN = find_id_nhan_vien_by_ma_nv(dataRow["MA_NHAN_VIEN"].ToString().Trim());
     v_us.datNGAY_LAP = DateTime.Now.Date;
     v_us.strNGUOI_LAP = CAppContext_201.getCurrentUserName();
     v_us.Insert();
     m_dc_id_hop_dong_moi_tao = v_us.dcID;
 }
        //check validate data
        private bool check_ma_hd()
        {
            DS_GD_HOP_DONG v_ds = new DS_GD_HOP_DONG();
            US_GD_HOP_DONG v_us = new US_GD_HOP_DONG();

            v_us.FillDataset(v_ds);

            string v_str_filter = "";
            v_str_filter = "MA_HOP_DONG = '" + m_txt_ma_hd.Text + "'";

            DataRow[] v_dr = v_ds.GD_HOP_DONG.Select(v_str_filter);

            if (v_dr.Count() != 0)
            {
                m_txt_ma_hd.BackColor = Color.Bisque;
                //  m_lbl_kiem_tra_ma_hd.Visible = true;
                //  m_lbl_kiem_tra_ma_hd.Text = "Đã có mã này rồi...";
                MessageBox.Show("Đã có mã này rồi!");
                return true;
            }
            else
            {
                m_txt_ma_hd.BackColor = Color.White;
                // m_lbl_kiem_tra_ma_hd.Visible = false;
                return false;
            }
        }
 //lay thong tin canh bao
 private DataTable get_hop_dong_het_han()
 {
     US_GD_HOP_DONG v_us_gd_hop_dong = new US_GD_HOP_DONG();
     DataSet v_ds = v_us_gd_hop_dong.LayDanhSachHDHetHanTrongThang();
     return v_ds.Tables[0];
 }
 private void grid_to_us_gd_hop_dong(US_GD_HOP_DONG v_us_gd_hd, DataRow data)
 {
     v_us_gd_hd.dcID_NHAN_VIEN = find_id_nv_by_ma_nv(data["MA_NHAN_VIEN"].ToString());
     v_us_gd_hd.dcID_LOAI_HOP_DONG = find_id_loai_hop_dong_by_ma(data["MA_LOAI_HOP_DONG"].ToString());
     v_us_gd_hd.dcID_CHUC_VU = find_id_chuc_vu(data["MA_CHUC_VU"].ToString());
     v_us_gd_hd.dcID_DON_VI = find_id_don_vi(data["MA_DON_VI"].ToString());
     v_us_gd_hd.dcID_LUONG_CHE_DO = find_id_lcd_by_ma_lcd(data["MA_CHUC_DANH_LCD"].ToString(), data["MA_MUC_LCD"].ToString());
     v_us_gd_hd.dcID_LOAI_LAO_DONG = find_id_tu_dien_by_ma_tu_dien(data["MA_LOAI_LAO_DONG"].ToString());
     v_us_gd_hd.dcSO_TIEN_LCD = find_so_tien_lcd(find_id_lcd_by_ma_lcd(data["MA_CHUC_DANH_LCD"].ToString(), data["MA_MUC_LCD"].ToString()));
     v_us_gd_hd.strMA_HOP_DONG = data["MA_HOP_DONG"].ToString();
     v_us_gd_hd.strNGUOI_LAP = CAppContext_201.getCurrentUserName();
     v_us_gd_hd.datNGAY_BAT_DAU = WinFormControls.FormatPostingDate(data["NGAY_BAT_DAU"].ToString());
     if (String.IsNullOrEmpty(data["NGAY_KET_THUC"].ToString()))
     {
         v_us_gd_hd.datNGAY_KET_THUC = v_us_gd_hd.datNGAY_BAT_DAU.AddYears(45);
     }
     else
     {
         v_us_gd_hd.datNGAY_KET_THUC = WinFormControls.FormatPostingDate(data["NGAY_KET_THUC"].ToString());
     }
     v_us_gd_hd.datNGAY_KY_HOP_DONG = WinFormControls.FormatPostingDate(data["NGAY_KI_HOP_DONG"].ToString());
     v_us_gd_hd.datNGAY_LAP = DateTime.Now.Date;
 }