public void loadMenuBtn() { //List<string> menuList = JRF.getMenuButtonName(); //foreach (string str in menuList) //{ // Button bt = new Button(); // bt.Name = str; // bt.Text = str; // menuFLP.Controls.Add(bt); // bt.Click += new System.EventHandler(this.menuBtn_Click); //} menuSetup = JRF.GetBtnPanelName(); pnItems = JRF.GetPanelItems(); foreach (PanelButton mS in menuSetup) { Button bt = new Button(); bt.Name = mS.BtnName; bt.Text = mS.BtnName; bt.Click += new System.EventHandler(this.menuBtn_Click); menuFLP.Controls.Add(bt); } if (!isAdmin) { menuFLP.Controls[1].Hide(); menuFLP.Controls[10].Hide(); menuFLP.Controls[11].Hide(); menuFLP.Controls[12].Hide(); } //menuFLP.AutoScroll = true; buttonShowControl(showOperation, showTreatment, showInventory); }
private void btnUpdateField_Click(object sender, EventArgs e) { // testing purposes foreach (DataRow dr in currentDataSet.Rows) { string t1 = dr[1].ToString(); Console.WriteLine("data table row => " + t1); } if (datagridDidPress) { try { string cbText = cbUpdateField.SelectedItem.ToString(); Console.WriteLine("CB update => " + cbText); if (JRF.GotInListStr(currentUpdateOption, cbText)) { // proceed MySql operation Console.WriteLine("update panel => " + currentPanel + "=> " + currentID); switch (currentPanel) { case "Order": int haha = JobOp.UpdateOrder(currentID, cbText); try { currentDataSet = JRFdataset.Table.getAllOrders().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } MessageBox.Show("Update Done"); dgvDbTable.DataSource = currentDataSet; dgvDbTable.Refresh(); break; default: break; } } else { ErrorMsg.UpdateOptionInvalid(); } } catch (Exception ex) { ErrorMsg.UpdateOptionNoSelect(); } } else { ErrorMsg.PlsSelectRow(); } }
private void logoutBtn_Click(object sender, EventArgs e) { // back to login screen JRF.Logout(this); }
public void switchPanelItem(string btnName) { currentPanel = btnName; // reset combo box items cbUpdateField.Items.Clear(); cbFilter1.Items.Clear(); // hide combobox filter cbFilter2.Hide(); cbFilter3.Hide(); cbFilter4.Hide(); switch (btnName) { case "Order": lblPanelTitle.Text = pnItems[0].PnTitle; lblId.Text = pnItems[0].Id; lblUpdateField.Text = pnItems[0].UpdateField; btnNewItem.Text = pnItems[0].BtnNew; btnEditItem.Text = pnItems[0].BtnEdit; btnUpdateField.Text = pnItems[0].BtnUpdate; currentSearchOption = JobOp.getOrderList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } currentUpdateOption = JRF.OrderStatusOption(); lblUpdateField.Hide(); btnUpdateField.Hide(); foreach (string str in currentUpdateOption) { cbUpdateField.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllOrders().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; break; case "Product": lblPanelTitle.Text = pnItems[1].PnTitle; lblId.Text = pnItems[1].Id; lblUpdateField.Text = pnItems[1].UpdateField; btnNewItem.Text = pnItems[1].BtnNew; btnEditItem.Text = pnItems[1].BtnEdit; btnUpdateField.Text = pnItems[1].BtnUpdate; currentSearchOption = JobOp.getProductList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllProduct().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; break; case "Sowing": lblPanelTitle.Text = pnItems[2].PnTitle; lblId.Text = pnItems[2].Id; lblUpdateField.Text = pnItems[2].UpdateField; btnNewItem.Text = pnItems[2].BtnNew; btnEditItem.Text = pnItems[2].BtnEdit; btnUpdateField.Text = pnItems[2].BtnUpdate; currentSearchOption = JobOp.getSowingJobList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllSowing().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; break; case "Harvesting": lblPanelTitle.Text = pnItems[3].PnTitle; lblId.Text = pnItems[3].Id; lblUpdateField.Text = pnItems[3].UpdateField; btnNewItem.Text = pnItems[3].BtnNew; btnEditItem.Text = pnItems[3].BtnEdit; btnUpdateField.Text = pnItems[3].BtnUpdate; currentSearchOption = JobOp.getHarvestingJobList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllHarvesting().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; break; case "Storage": lblPanelTitle.Text = pnItems[4].PnTitle; lblId.Text = pnItems[4].Id; lblUpdateField.Text = pnItems[4].UpdateField; btnNewItem.Text = pnItems[4].BtnNew; btnEditItem.Text = pnItems[4].BtnEdit; btnUpdateField.Text = pnItems[4].BtnUpdate; currentSearchOption = JobOp.getStoringJobList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllStoringJobStorage().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; break; case "Fertilising": lblPanelTitle.Text = pnItems[5].PnTitle; lblId.Text = pnItems[5].Id; lblUpdateField.Text = pnItems[5].UpdateField; btnNewItem.Text = pnItems[5].BtnNew; btnEditItem.Text = pnItems[5].BtnEdit; btnUpdateField.Text = pnItems[5].BtnUpdate; currentSearchOption = JobOp.getFertilisingList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllFertilising().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; break; case "Pest Control": lblPanelTitle.Text = pnItems[6].PnTitle; lblId.Text = pnItems[6].Id; lblUpdateField.Text = pnItems[6].UpdateField; btnNewItem.Text = pnItems[6].BtnNew; btnEditItem.Text = pnItems[6].BtnEdit; btnUpdateField.Text = pnItems[6].BtnUpdate; currentSearchOption = JobOp.getPesticideJobList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllPests().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; break; case "Farm": lblPanelTitle.Text = pnItems[7].PnTitle; lblId.Text = pnItems[7].Id; lblUpdateField.Text = pnItems[7].UpdateField; btnNewItem.Text = pnItems[7].BtnNew; btnEditItem.Text = pnItems[7].BtnEdit; btnUpdateField.Text = pnItems[7].BtnUpdate; //lblUpdateField.Hide(); //cbUpdateField.Hide(); //btnUpdateField.Hide(); //btnReset.Hide(); currentSearchOption = JobOp.getFarmList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllFarm().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; break; case "Employee": lblPanelTitle.Text = pnItems[8].PnTitle; lblId.Text = pnItems[8].Id; lblUpdateField.Text = pnItems[8].UpdateField; btnNewItem.Text = pnItems[8].BtnNew; btnEditItem.Text = pnItems[8].BtnEdit; btnUpdateField.Text = pnItems[8].BtnUpdate; currentSearchOption = JobOp.getEmployeeList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllEmployee().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; break; case "Customer": lblPanelTitle.Text = pnItems[9].PnTitle; lblId.Text = pnItems[9].Id; lblUpdateField.Text = pnItems[9].UpdateField; btnNewItem.Text = pnItems[9].BtnNew; btnEditItem.Text = pnItems[9].BtnEdit; btnUpdateField.Text = pnItems[9].BtnUpdate; currentSearchOption = JobOp.getCustomerList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllCustomer().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; break; case "Storeroom": lblPanelTitle.Text = pnItems[10].PnTitle; lblId.Text = pnItems[10].Id; lblUpdateField.Text = pnItems[10].UpdateField; btnNewItem.Text = pnItems[10].BtnNew; btnEditItem.Text = pnItems[10].BtnEdit; btnUpdateField.Text = pnItems[10].BtnUpdate; currentSearchOption = JobOp.getStoreroomList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllStoreroom().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; break; case "Vehicle": lblPanelTitle.Text = pnItems[11].PnTitle; lblId.Text = pnItems[11].Id; lblUpdateField.Text = pnItems[11].UpdateField; btnNewItem.Text = pnItems[11].BtnNew; btnEditItem.Text = pnItems[11].BtnEdit; btnUpdateField.Text = pnItems[11].BtnUpdate; currentSearchOption = JobOp.getVehicleList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllVehicle().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; break; case "Crop": lblPanelTitle.Text = pnItems[12].PnTitle; lblId.Text = pnItems[12].Id; lblUpdateField.Text = pnItems[12].UpdateField; btnNewItem.Text = pnItems[12].BtnNew; btnEditItem.Text = pnItems[12].BtnEdit; btnUpdateField.Text = pnItems[12].BtnUpdate; currentDataSet = JRFdataset.Table.getAllCrop().Tables[0]; currentSearchOption = JobOp.getCropList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllCrop().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; break; case "Fertiliser": lblPanelTitle.Text = pnItems[13].PnTitle; lblId.Text = pnItems[13].Id; lblUpdateField.Text = pnItems[13].UpdateField; btnNewItem.Text = pnItems[13].BtnNew; btnEditItem.Text = pnItems[13].BtnEdit; btnUpdateField.Text = pnItems[13].BtnUpdate; currentSearchOption = JobOp.getFertiliserList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllFertiliser().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; break; case "Pesticide": lblPanelTitle.Text = pnItems[14].PnTitle; lblId.Text = pnItems[14].Id; lblUpdateField.Text = pnItems[14].UpdateField; btnNewItem.Text = pnItems[14].BtnNew; btnEditItem.Text = pnItems[14].BtnEdit; btnUpdateField.Text = pnItems[14].BtnUpdate; currentSearchOption = JobOp.getPesticideList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllPesticide().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; break; case "Box": lblPanelTitle.Text = pnItems[15].PnTitle; lblId.Text = pnItems[15].Id; lblUpdateField.Text = pnItems[15].UpdateField; btnNewItem.Text = pnItems[15].BtnNew; btnEditItem.Text = pnItems[15].BtnEdit; btnUpdateField.Text = pnItems[15].BtnUpdate; currentSearchOption = JobOp.getBoxList(); foreach (string str in currentSearchOption) { cbFilter1.Items.Add(str); } try { currentDataSet = JRFdataset.Table.getAllBox().Tables[0]; } catch (Exception ex) { MessageBox.Show("No Data"); } dgvDbTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; break; default: break; } dgvDbTable.DataSource = currentDataSet; dgvDbTable.ScrollBars = ScrollBars.Both; }