} // ctor private void FormImportEclaim_DBF_TXT_FormClosing(object sender, FormClosingEventArgs e) // OK5-ROUGH { if (registerManager != null) { registerManager.IsWaitClose = true; // mai: to pause RegisterManager-Importing-Process. if (!isByPassConfirmClosingDialog) // mai: check if Bypass this ConfirmClosingDialog when finished all jobs. { // mai: ask user to confirm for closing this form, in this case if user click on btn-NO to NOT-Closing this form. DialogResult dialogResult = FormMyMessageBox.Show("╥Хр╧╣Им╖║рцб║Юет║║рц╧сЮ╒Ир╒ИмаыеЦ╙ХкцвмДаХ", MyConst.APP_NAME, MessageBoxButtons.YesNo); // mai // OK // Ok if (dialogResult == DialogResult.No) // mai // WK { e.Cancel = true; // mai: Cancel the Closing-Event from closing the form. registerManager.IsWaitClose = false; // reset // mai: to continue RegisterManager-Importing-Process. return; } // if (dialogResult == DialogResult.No) } // if (!isByPassConfirmClosingDialog) registerManager.IsClose = true; } // if (registerManager != null) //--------------------------------- ImportLog.deleteImportLog(); // mai added this.DialogResult = DialogResult.OK; // mai added why why } // FormImportEclaim_DBF_TXT_FormClosing
} // btnxBrowseFolder_Click private void btnxImport_Click(object sender, EventArgs e) // OK5 { if (!IsImporting) // mai: OK { // mai: Start "registerManager.ImportDBF_Phase1()/ImportTXT_Phase1()": //================================================================== ImportLog.deleteImportLog(); //================================================================== bool updatePendingApprovedTransaction = false; // mai: init with "false" if (RegisterManager.chkPendingApprovedTransaction()) // OK { using (FormAlertUpdatePendingApprovedTransaction formAlertUpdatePendingApprovedTransaction = new FormAlertUpdatePendingApprovedTransaction()) { DialogResult dialogResult = formAlertUpdatePendingApprovedTransaction.ShowDialog(); if (dialogResult == DialogResult.OK) { updatePendingApprovedTransaction = formAlertUpdatePendingApprovedTransaction.UpdatePendingApprovedTransaction; // mai: values preserved after close! } } } // if (RegisterManager.chkPendingApprovedTransaction()) //--------------------------------- if (updatePendingApprovedTransaction) { IsImporting = false; // mai: reset this.Close(); // will calling "FormClosing()" return; } //================================================================== if (fileTypes == Import_Const.FileTypes.DBF) { lblxMsg.Text = $@"║сея╖╢сЮ╧т╧║рц╧сЮ╒Ир╒Имаые╗р║Д©еЛ DBF"; } else if (fileTypes == Import_Const.FileTypes.TXT) { lblxMsg.Text = $@"║сея╖╢сЮ╧т╧║рц╧сЮ╒Ир╒Имаые╗р║Д©еЛ TXT"; } pgbImport.Value = 0; //------------------------------------------------------------------ picBxLoading.Visible = true; //--------------------------------- btnxBrowseFolder.Enabled = false; //--------------------------------- btnxImport.Text = $@"б║Юет║"; btnxImport.Enabled = true; //--------------------------------- btnxClose.Enabled = true; //--------------------------------- btnxExportLog.Enabled = false; //================================================================== IsImporting = true; // mai: telling that going to do "registerManager.ImportDBF()/ImportText()" and telling that thread is running for importing and use to stop thread when press import-btn again, before start thread set this to true!!! //------------------------------------------------------------------ // mai: share with "registerManager.ImportDBF_Phase1()/ImportTXT_Phase1()--btnxImport_Click()" and "_frmImportSummary.RegisterManager--importFinished()" registerManager = new RegisterManager(); // Clear old value // org // mai: reset by create new instance. // mai: OK registerManager.CallBackForm = this; // mai: use to call member of this Form from other Form, e.g. _frmImportEclaim.Import!!! registerManager.FolderPath = txtBxxBrowseFolder.Text; if (fileTypes == Import_Const.FileTypes.DBF) { new Thread(new ThreadStart(registerManager.importDBF_Phase1)).Start(); } else if (fileTypes == Import_Const.FileTypes.TXT) { new Thread(new ThreadStart(registerManager.importTXT_Phase1)).Start(); } } // if (!IsImporting) else { // mai: Cancel thread "registerManager.ImportDBF_Phase1()/ImportTXT_Phase1()" with "IsImporting = false": // mai: added: //DialogResult dialogResult = FormMyMessageBox.Show("╥Хр╧╣Им╖║рцб║Юет║║рц╧сЮ╒Ир╒ИмаыеЦ╙ХкцвмДаХ", MyConst.APP_NAME, MessageBoxButtons.YesNo); //if (dialogResult == DialogResult.Yes) { //================================================================== lblxMsg.Text = $@"║сея╖б║Юет║║рц╧сЮ╒Ир╒Имаые"; //pgbImport.Value = 0; //------------------------------------------------------------------ picBxLoading.Visible = true; //--------------------------------- btnxBrowseFolder.Enabled = false; //--------------------------------- btnxImport.Text = $@"╧сЮ╒Ир╒Имаые"; btnxImport.Enabled = false; //--------------------------------- btnxClose.Enabled = false; //--------------------------------- btnxExportLog.Enabled = false; //================================================================== IsImporting = false; // mai: reset, and also use this var to stop thread of "registerManager.ImportDBF_Phase1()/ImportTXT_Phase1()". } // if--dialogResult-confirm-cancel } // else // if (!IsImporting) } // btnxImport_Click