/// <summary> /// Disables the menus and Logouts company /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void logoutToolStripMenuItem_Click_1(object sender, EventArgs e) { try { List<Form> openForms = new List<Form>(); foreach (Form f in Application.OpenForms) openForms.Add(f); foreach (Form f in openForms) { if (f.Name != "formMDI") f.Close(); } MDIObj = this; PublicVariables._decCurrentCompanyId = 0; MenuStripDisabling(); companyToolStripMenuItem.Enabled = true; editCompanyToolStripMenuItem1.Enabled = false; BackUpToolStripMenuItem.Enabled = false; RestoreToolStripMenuItem.Enabled = false; dateToolStripMenuItem.Enabled = false; exitToolStripMenuItem.Enabled = true; createCompanyToolStripMenuItem.Enabled = true; SelectCompanyToolStripMenuItem.Enabled = true; logoutToolStripMenuItem.Enabled = false; formMDI.MDIObj.Text = "OpenMiracle"; CompanySP spCompany = new CompanySP(); decimal decCompanyCount = spCompany.CompanyCount(); if (decCompanyCount == 1) { PublicVariables._decCurrentCompanyId = spCompany.CompanyGetIdIfSingleCompany(); CurrentDate(); frmLogin frmLoginObj = new frmLogin(); frmLoginObj.MdiParent = MDIObj; frmLoginObj.CallFromFormMdi(this); } else if (decCompanyCount < 1) { CurrentDateBefore(); frmCompanyCreation frmCompanyCreationObj = new frmCompanyCreation(); frmCompanyCreationObj.MdiParent = formMDI.MDIObj; frmCompanyCreationObj.CallFromFormMdi(); } else { PublicVariables._decCurrentCompanyId = 0; CompanyPathSP spCompanyPath = new CompanyPathSP(); decimal decDefaultCompanyId = spCompanyPath.CompanyViewForDefaultCompany(); if (decDefaultCompanyId > 0) { PublicVariables._decCurrentCompanyId = decDefaultCompanyId; CurrentDate(); frmLogin frmLoginObj = new frmLogin(); frmLoginObj.MdiParent = formMDI.MDIObj; frmLoginObj.CallFromFormMdi(this); } else { CurrentDate(); frmSelectCompany frmSelectCompanyObj = new frmSelectCompany(); frmSelectCompanyObj.MdiParent = formMDI.MDIObj; frmSelectCompanyObj.CallFromMdi(); } } CurrentSettings(); } catch (Exception ex) { MessageBox.Show("MDI 214: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Form Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void formMDI_Load(object sender, EventArgs e) { try { CheckNewVersionComesOfOpenMiracle(); MDIObj = this; MenuStripDisabling(); companyToolStripMenuItem.Enabled = true; editCompanyToolStripMenuItem1.Enabled = false; BackUpToolStripMenuItem.Enabled = false; RestoreToolStripMenuItem.Enabled = false; dateToolStripMenuItem.Enabled = false; exitToolStripMenuItem.Enabled = true; createCompanyToolStripMenuItem.Enabled = true; SelectCompanyToolStripMenuItem.Enabled = true; logoutToolStripMenuItem.Enabled = false; logoutToolStripMenuItem.Enabled = false; CompanySP spCompany = new CompanySP(); decimal decCompanyCount = spCompany.CompanyCount(); if (decCompanyCount != -1) { if (decCompanyCount == 1) { PublicVariables._decCurrentCompanyId = spCompany.CompanyGetIdIfSingleCompany(); CurrentDate(); frmLogin frmLoginObj = new frmLogin(); frmLoginObj.MdiParent = MDIObj; frmLoginObj.CallFromFormMdi(this); } else if (decCompanyCount < 1) { CurrentDateBefore(); frmCompanyCreation frmCompanyCreationObj = new frmCompanyCreation(); frmCompanyCreationObj.MdiParent = formMDI.MDIObj; frmCompanyCreationObj.CallFromFormMdi(); SelectCompanyToolStripMenuItem.Enabled = false; } else { PublicVariables._decCurrentCompanyId = 0; CompanyPathSP spCompanyPath = new CompanyPathSP(); decimal decDefaultCompanyId = spCompanyPath.CompanyViewForDefaultCompany(); if (decDefaultCompanyId > 0) { PublicVariables._decCurrentCompanyId = decDefaultCompanyId; CurrentDate(); frmLogin frmLoginObj = new frmLogin(); frmLoginObj.MdiParent = formMDI.MDIObj; frmLoginObj.CallFromFormMdi(this); } else { CurrentDate(); frmSelectCompany frmSelectCompanyObj = new frmSelectCompany(); frmSelectCompanyObj.MdiParent = formMDI.MDIObj; frmSelectCompanyObj.CallFromMdi(); } } CurrentSettings(); } else { createCompanyToolStripMenuItem.Enabled = false; SelectCompanyToolStripMenuItem.Enabled = false; } } catch (Exception ex) { MessageBox.Show("MDI 40 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }