public MainDashboard(int userID) { InitializeComponent(); USER_ID = userID; int userPermission = dalUser.getPermissionLevel(USER_ID); sPPToolStripMenuItem.Visible = true; if (userPermission >= ACTION_LVL_FOUR) { sPPToolStripMenuItem.Visible = true; adminToolStripMenuItem.Visible = true; orderToolStripMenuItem1.Visible = true; productionToolStripMenuItem.Visible = true; } else if (userPermission >= ACTION_LVL_TWO) { forecastToolStripMenuItem.Visible = true; //sPPToolStripMenuItem.Visible = false; adminToolStripMenuItem.Visible = false; orderToolStripMenuItem1.Visible = true; productionToolStripMenuItem.Visible = true; } else { //sPPToolStripMenuItem.Visible = false; pMMAToolStripMenuItem.Visible = false; forecastToolStripMenuItem.Visible = false; adminToolStripMenuItem.Visible = false; orderToolStripMenuItem1.Visible = true; productionToolStripMenuItem.Visible = false; } }
private void button1_Click(object sender, EventArgs e) { string username = textBox1.Text; string password = textBox2.Text; if (validation()) { int userID = dalUser.userLogin(username, password); if (userID != -1) { int userPermission = dalUser.getPermissionLevel(userID); if (userPermission < MainDashboard.ACTION_LVL_ONE) { MessageBox.Show("Access denied. Contact your administrator."); tool.historyRecord(text.LogIn, text.Failed, DateTime.Now, userID); } else { frmLoading.ShowLoadingScreen(); tool.historyRecord(text.LogIn, text.Success, DateTime.Now, userID); MainDashboard frm = new MainDashboard(userID); frm.Show(); frmLoading.CloseForm(); Hide(); } } else { MessageBox.Show("username or password invalid. please try again."); } } }
private void frmDeliverySchedule_Load(object sender, EventArgs e) { ShowOrHideFilter(); if (dalUser.getPermissionLevel(MainDashboard.USER_ID) <= 3) { tlpDeliveryList.RowStyles[2] = new RowStyle(SizeType.Absolute, 0f); } LoadDeliverySchedule(); LoadSalesReport(); }
//handle the row selection on right click private void dgvAction_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { Cursor = Cursors.WaitCursor; // change cursor to hourglass type //handle the row selection on right click if (e.Button == MouseButtons.Right && e.RowIndex > -1 && dalUser.getPermissionLevel(MainDashboard.USER_ID) >= MainDashboard.ACTION_LVL_TWO) { ContextMenuStrip my_menu = new ContextMenuStrip(); dgvAction.CurrentCell = dgvAction.Rows[e.RowIndex].Cells[e.ColumnIndex]; // Can leave these here - doesn't hurt dgvAction.Rows[e.RowIndex].Selected = true; dgvAction.Focus(); int rowIndex = dgvAction.CurrentCell.RowIndex; try { my_menu.Items.Add("Edit").Name = "Edit"; my_menu.Items.Add("Undo").Name = "Undo"; string action = dgvAction.Rows[rowIndex].Cells["action"].Value.ToString(); int actionID = Convert.ToInt32(dgvAction.Rows[rowIndex].Cells["order_action_id"].Value); bool active = dalOrderAction.checkIfActive(actionID); if (active && action.Equals("RECEIVE")) { my_menu.Show(Cursor.Position.X, Cursor.Position.Y); contextMenuStrip1 = my_menu; my_menu.ItemClicked += new ToolStripItemClickedEventHandler(my_menu_ItemClicked); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } Cursor = Cursors.Arrow; // change cursor to normal type }