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 save_data()
        {
            if(m_grv_hop_dong.RowCount < 1)
            {
                XtraMessageBox.Show("Chưa có dữ liệu để lưu!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if(!check_all_is_ok())
            {
                return;
            }
            SplashScreenManager.ShowForm(this, typeof(SplashScreen1), true, true, false);
            US_GD_HOP_DONG v_us_gd_hd = new US_GD_HOP_DONG();
            int v_i_row = 0;
            try
            {
                for(v_i_row = 0; v_i_row < m_grv_hop_dong.RowCount; v_i_row++)
                {
                    v_us_gd_hd.ClearAllFields();
                    var data = m_grv_hop_dong.GetDataRow(v_i_row);
                    grid_to_us_gd_hop_dong(v_us_gd_hd, data);
                    v_us_gd_hd.BeginTransaction();
                    v_us_gd_hd.Insert();
                    if(!ExecuteFuntion.KiemTraNhanVienCoCongTac(v_us_gd_hd.dcID_NHAN_VIEN))
                    {
                        US_GD_CONG_TAC v_us = new US_GD_CONG_TAC();
                        v_us.dcID_DON_VI = v_us_gd_hd.dcID_DON_VI;
                        v_us.dcID_LOAI_CONG_TAC = CONST_ID_LOAI_CONG_TAC.CHINH_THUC;
                        v_us.dcID_NHAN_VIEN = v_us_gd_hd.dcID_NHAN_VIEN;
                        v_us.dcID_VI_TRI = v_us_gd_hd.dcID_CHUC_VU;
                        v_us.dcSO_HO_SO = ExecuteFuntion.GetSoHoSoNext(v_us_gd_hd.dcID_DON_VI, v_us_gd_hd.dcID_CHUC_VU, v_us_gd_hd.dcID_NHAN_VIEN);
                        v_us.strDA_XOA = "N";
                        v_us.strNGUOI_LAP = CAppContext_201.getCurrentUserName();
                        v_us.datNGAY_LAP = DateTime.Now.Date;
                        v_us.datNGAY_BAT_DAU = v_us_gd_hd.datNGAY_BAT_DAU;
                        v_us.UseTransOfUSObject(v_us_gd_hd);
                        v_us.Insert();
                    }
                    v_us_gd_hd.CommitTransaction();
                    SplashScreenManager.Default.SendCommand(SplashScreen1.SplashScreenCommand.SetProgress, (int)((decimal)v_i_row / (decimal)m_grv_hop_dong.RowCount * 100));
                }

                CHRM_BaseMessages.MsgBox_Infor("Đã lưu dữ liệu thành công");
            }
            catch(Exception)
            {
                if(v_us_gd_hd.is_having_transaction())
                {
                    v_us_gd_hd.Rollback();
                }
                if(v_i_row >= 1)
                {
                    throw new Exception("Có lỗi xảy ra. Dữ liệu lưu chưa thành công!\nĐã lưu thành công đến dòng thứ " + v_i_row + " với mã nhân viên " + m_grv_hop_dong.GetRowCellValue(v_i_row - 1, ExcelHopDong.MA_NHAN_VIEN).ToString());
                }
                else
                {
                    throw new Exception("Có lỗi xảy ra. Dữ liệu lưu chưa được lưu!");
                }
            }
            finally
            {
                SplashScreenManager.CloseForm(false);
            }
        }
 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;
 }
        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);

                    v_us_gd_hd.BeginTransaction();
                    v_us_gd_cong_tac.UseTransOfUSObject(v_us_gd_hd);
                    v_us_gd_cong_tac.Insert();
                    v_us_gd_hs_lns.UseTransOfUSObject(v_us_gd_hd);
                    v_us_gd_hs_lns.Insert();
                    v_us_gd_hd.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;
            }
        }