BKI_DichVuMatDat.NghiepVu.NhanSu.f001_import_cong_tac.save_data C# (CSharp) Метод

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

private save_data ( ) : void
Результат void
        private void save_data()
        {
            if(m_grv_cong_tac.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_CONG_TAC v_us_gd_ct = new US_GD_CONG_TAC();
            int v_i_row = 0;
            try
            {

                for(v_i_row = 0; v_i_row < m_grv_cong_tac.RowCount; v_i_row++)
                {
                    v_us_gd_ct.BeginTransaction();
                    v_us_gd_ct.ClearAllFields();
                    var data = m_grv_cong_tac.GetDataRow(v_i_row);
                    grid_to_us_gd_cong_tac(v_us_gd_ct, data);
                    v_us_gd_ct.Insert();
                    v_us_gd_ct.CommitTransaction();
                    SplashScreenManager.Default.SendCommand(SplashScreen1.SplashScreenCommand.SetProgress, (int)((decimal)v_i_row / (decimal)m_grv_cong_tac.RowCount * 100));
                }

                //Sau do phai cap nhat lai so ho so, chua biet lam

                CHRM_BaseMessages.MsgBox_Infor("Đã lưu dữ liệu thành công");
            }
            catch(Exception)
            {
                if(v_us_gd_ct.is_having_transaction())
                {
                    v_us_gd_ct.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_cong_tac.GetRowCellValue(v_i_row - 1, ExcelCongTac.MA_NHAN_VIEN).ToString());
                }
                else
                {
                    throw new Exception("Có lỗi xảy ra. Dữ liệu lưu chưa được lưu!");
                }
                throw;
            }
            finally
            {
                SplashScreenManager.CloseForm(false);
            }
        }