BKI_DichVuMatDat.NghiepVu.HopDong.f002_import_hop_dong_v2.save_data C# (CSharp) Метод

save_data() приватный Метод

private save_data ( ) : void
Результат void
        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);
            }
        }