I want to check if the user has permission to enter the screen by letting them log in before opening the formLoad, if not, I want to close the form here but I can’t.
normally I just call this.Close()
But in epicor can this close event be used?
private void MainController_Load(object sender, EventArgs args)
{
// Add Event Handler Code
this.baseToolbarsManager.Tools["RefreshTool"].SharedProps.Enabled = false;//khóa nút Refresh
//this.baseToolbarsManager.Tools["RefreshAllTool"].SharedProps.Enabled = false;//khóa nút Refresh All
epiButtonC_Select.Text = "Select All Rows";
tbl_POAppreve = new DataTable();
tbl_POSendMail = new DataTable();
tbl_POSendMailTracker = new DataTable();
epiDateTimeEditorC_FromDay.Value = DateTime.Now.Date.AddMonths(-3);
epiDateTimeEditorC_ToDate.Value = DateTime.Now.Date;
epiUltraComboC_ReportStyle.DropDownStyle = UltraComboStyle.DropDownList;//không cho nhập text
epiUltraComboC_EmailFrom.DropDownStyle = UltraComboStyle.DropDownList;//không cho nhập text
epiTextBoxC_UserName.ReadOnly = true;
epiTextBoxC_Password.ReadOnly = true;
epiUltraComboC_EmailFrom.ReadOnly = true;
//Form login
frmLogin = new Form();
InitializeLogin(frmLogin);
// Display the form as a modal dialog box.
DialogResult dr = frmLogin.ShowDialog();
if (dr == DialogResult.OK)
{
LoadDataInfo();
}
else
{
this.MainController.Closing += (sende,e)=>
{
e.Cancel = false;
// do stuff
};//new System.ComponentModel.CancelEventHandler(this.MainController_Closing);
//MainController_Closing(sender, null);
}
//cấu hình ToolTip thuộc tính của control
System.Windows.Forms.ToolTip toolTip_epiButtonC = new System.Windows.Forms.ToolTip();
//toolTip_epiButtonC.AutoPopDelay = 5000;
//toolTip_epiButtonC.InitialDelay = 1000;
//toolTip_epiButtonC.ReshowDelay = 500;
// Force the ToolTip text to be displayed whether or not the form is active.
toolTip_epiButtonC.ShowAlways = true;
toolTip_epiButtonC.SetToolTip(this.txtUser, "Vui lòng nhập user của máy tính đang sử dụng để gửi Mail");
toolTip_epiButtonC.SetToolTip(this.epiTextBoxC_UserName, "Vui lòng nhập user của máy tính đang sử dụng để gửi Mail");
toolTip_epiButtonC.SetToolTip(this.txtPassword, "Vui lòng nhập mật khẩu của máy tính đang sử dụng Mail");
toolTip_epiButtonC.SetToolTip(this.epiTextBoxC_Password, "Vui lòng nhập mật khẩu của máy tính đang sử dụng Mail");
toolTip_epiButtonC.SetToolTip(this.epiButtonC_Load, "Sử dụng nút này để lấy PO đã Approve cần gửi Mail");
toolTip_epiButtonC.SetToolTip(this.epiButtonC_SendMaill, "Sử dụng nút này để gửi mail các PO đang được chọn!");
toolTip_epiButtonC.SetToolTip(this.epiUltraComboC_ReportStyle, "Vui lòng chọn kiểu Report style muốn xem hoặc gửi Mail!");
toolTip_epiButtonC.SetToolTip(this.EmailCombo, "Vui lòng chọn EMail gửi đi!");
toolTip_epiButtonC.SetToolTip(this.epiUltraComboC_EmailFrom, "Vui lòng chọn EMail gửi đi!");
toolTip_epiButtonC.SetToolTip(this.epiButtonC_UpdateSendMail, "Sử dụng nút này để cập nhật trạng thái gửi mail các PO đang được chọn! (PO được gửi mail thủ công)");
}
is there a solution to help me close the form right away, formload if I use Application.Exit( ) then shut down the whole program
I use the FormShow event that occurs after the FormLoad to solve the problem
EpiBaseForm frmMain;
frmMain = (EpiBaseForm)(csm.GetNativeControlReference("B564E070-3328-4f86-BF70-DD1C139CCB21"));
private void MainController_Shown(object sender, EventArgs e)
{
// Do work Here
// Display the form as a modal dialog box.
DialogResult dr = frmLogin.ShowDialog();
if (dr == DialogResult.OK)
{
LoadDataInfo();
}
else
{
frmMain.Close();
}
}
private void MainController_Load(object sender, EventArgs args)
Thank you so much have a nice day!