private void SelectBilling(int index) { MasterFrom mf = parentFormName; Panel panelMaster = mf.Controls["pnlMaster"] as Panel; RemoveAllInstances(); BillingUC.Instance = null; if (!panelMaster.Controls.Contains(BillingUC.Instance)) { panelMaster.Controls.Add(BillingUC.Instance); BillingUC.Instance.BringToFront(); } else { BillingUC.Instance.BringToFront(); } ControlCollection cc = panelMaster.Controls; controls = cc[0].Controls.Find("tbBilling", true); TabControl tc = (TabControl)controls[0]; TabPage tp = tc.TabPages[index]; tc.SelectTab(tp); }
private void SelectStockTabs(int index) { MasterFrom mf = parentFormName; Panel panelMaster = mf.Controls["pnlMaster"] as Panel; //RemoveAllInstances(); if (!panelMaster.Controls.Contains(StockUC.Instance)) { panelMaster.Controls.Add(StockUC.Instance); StockUC.Instance.BringToFront(); } else { StockUC.Instance.BringToFront(); } ControlCollection cc = panelMaster.Controls; controls = cc[0].Controls.Find("tbStock", true); TabControl tc = (TabControl)controls[0]; TabPage tp = tc.TabPages[index]; if (tc.TabPages.Count == 4) { //TabPage reportsTab = tc.TabPages[3]; //if (employeeType == (int)Constants.EMPLOYEETYPE.STAFF || employeeType == (int)Constants.EMPLOYEETYPE.TRAINEE) // tc.TabPages.Remove(reportsTab); } tc.SelectTab(tp); }
private void LogOut_Click(object sender, EventArgs e) { isLogOut = true; MasterFrom mf = parentFormName; Panel pnlMaster = mf.Controls["pnlMaster"] as Panel; MenuStrip mainMenu = mf.Controls["menuMain"] as MenuStrip; mainMenu.Hide(); pnlMaster.Controls.Remove(StockUC.Instance); pnlMaster.Controls.Remove(CompanyUC.Instance); pnlMaster.Controls.Remove(BillingUC.Instance); if (!pnlMaster.Controls.Contains(LoginUC.Instance)) { pnlMaster.Controls.Add(LoginUC.Instance); LoginUC.Instance.BringToFront(); } else { LoginUC.Instance.BringToFront(); } txtUName.Clear(); txtPass.Clear(); Label lblUserName = mf.Controls["lblUserName"] as Label; lblUserName.Text = string.Empty; }
private void RemoveAllInstances() { MasterFrom mf = parentFormName; Panel panelMaster = mf.Controls["pnlMaster"] as Panel; panelMaster.Controls.Remove(StockUC.Instance); panelMaster.Controls.Remove(HomePage.Instance); panelMaster.Controls.Remove(CompanyUC.Instance); panelMaster.Controls.Remove(BillingUC.Instance); }
private void btnLogin_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtUName.Text) || String.IsNullOrEmpty(txtPass.Text)) { MessageBox.Show(Constants.INVALID_LOGIN); } else { using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection()) { var loginResult = context.GET_ValidateLogin(txtUName.Text, txtPass.Text).FirstOrDefault(); if (loginResult == null) { MessageBox.Show(Constants.INVALID_LOGIN); } else { employeeType = loginResult.Designation_Id; employeeName = loginResult.FirstName; MasterFrom masterForm = (MasterFrom)this.Parent.Parent; Label lblUserName = masterForm.Controls["lblUserName"] as Label; lblUserName.Text = Constants.WELCOME + " " + employeeName; if (parentFormName == null) { return; } else { parentFormName = masterForm; } Panel panelMaster = masterForm.Controls["pnlMaster"] as Panel; panelMaster.Controls.Remove(LoginUC.Instance); HomePage.Instance = null; panelMaster.Controls.Add(HomePage.Instance); HomePage.Instance.BringToFront(); BuildMenu(masterForm, employeeType); } } } }
private void BuildMenu(MasterFrom masterForm, int?empType) { MenuStrip mainMenu = masterForm.Controls["menuMain"] as MenuStrip; mainMenu.Items.Clear(); mainMenu.Show(); ToolStripMenuItem item, submenu, stock, company, billing; submenu = new ToolStripMenuItem(); submenu.Text = Constants.HOME; item = new ToolStripMenuItem(); item.Text = Constants.LOG_OUT; item.Click += LogOut_Click; submenu.DropDownItems.Add(item); item = new ToolStripMenuItem(); item.Click += new EventHandler(exitToolStripMenuItem_Click); item.Text = Constants.EXIT; submenu.DropDownItems.Add(item); stock = new ToolStripMenuItem(); stock.Text = Constants.STOCK; item = new ToolStripMenuItem(); item.Text = Constants.NEW_STOCK; item.Click += Item_Click; stock.DropDownItems.Add(item); item = new ToolStripMenuItem(); item.Text = Constants.UPDATE_STOCK; item.Click += Item_Click; stock.DropDownItems.Add(item); item = new ToolStripMenuItem(); item.Text = Constants.DELETE_STOCK; item.Click += Item_Click; stock.DropDownItems.Add(item); company = new ToolStripMenuItem(); company.Text = Constants.COMPANY; item = new ToolStripMenuItem(); item.Text = Constants.ADD_COMPANY; item.Click += Item_Click; company.DropDownItems.Add(item); item = new ToolStripMenuItem(); item.Text = Constants.REMOVE_COMPANY; item.Click += Item_Click; company.DropDownItems.Add(item); item = new ToolStripMenuItem(); item.Text = Constants.VIEW_COMPANIES; item.Click += Item_Click; company.DropDownItems.Add(item); mainMenu.Items.Add(submenu); mainMenu.Items.Add(stock); mainMenu.Items.Add(company); if (empType == (int)Constants.EMPLOYEETYPE.ADMIN || empType == (int)Constants.EMPLOYEETYPE.MANAGER) { item = new ToolStripMenuItem(); item.Text = Constants.REPORTS; item.Click += Item_Click; stock.DropDownItems.Add(item); billing = new ToolStripMenuItem(); billing.Text = Constants.SALES; item = new ToolStripMenuItem(); item.Text = Constants.NEW_BILL; item.Click += Item_Click; billing.DropDownItems.Add(item); item = new ToolStripMenuItem(); item.Text = Constants.VIEW_BILLS; item.Click += Item_Click; billing.DropDownItems.Add(item); mainMenu.Items.Add(billing); } }