private void button1_Click(object sender, EventArgs e) { switch (deptCode) { case "AM": this.Hide(); EditMenu em = new EditMenu(this, 0); em.Show(); break; case "RM": this.Hide(); PurchaseRequest pr = new PurchaseRequest(this, restNo, StaffNo); pr.Show(); break; case "PM": this.Hide(); TypeofAgreementMenu tam = new TypeofAgreementMenu(staffName, this); tam.Show(); break; case "CM": this.Hide(); Category cat = new Category(this); cat.Show(); break; case "WC": this.Hide(); WHViewDPI dpi = new WHViewDPI(this); dpi.Show(); break; case "AD": this.Hide(); TypeofAgreementMenu adtam = new TypeofAgreementMenu(staffName, this); adtam.Show(); break; } }
public WHGenerateDN(WHViewDPI vDPI, String iId, String rno, String status) { InitializeComponent(); this.vDPI = vDPI; this.iId = iId; this.rno = rno; this.status = status; cnn.Open(); MySqlDataAdapter sda = new MySqlDataAdapter("SELECT Distinct DI.ItemID, ItemName,ItemDescription, DI.quantity as Needs, DI.quantity, S.quantity as Stock FROM DespatchInstruction DI, WarehouseStock_new S, Item I WHERE DI.ItemID=I.ItemID and DI.ItemID=S.ItemID and DesID = '" + iId + "';", cnn); DataTable dt = new DataTable(); sda.Fill(dt); dGVItem.DataSource = dt; int i = 0; maxQty = new int[dGVItem.RowCount]; stock = new int[dGVItem.RowCount]; foreach (DataGridViewRow row in dGVItem.Rows) { int quantity = Convert.ToInt32(row.Cells["quantity"].Value); String itemID = Convert.ToString(row.Cells["ItemID"].Value); stock[i] = Convert.ToInt32(row.Cells["Stock"].Value); MySqlCommand getQuantity = new MySqlCommand("Select quantity from DespatchInstruction WHERE ItemID = '" + itemID + "' and DesID = '" + iId + "';", cnn); maxQty[i] = Convert.ToInt32(getQuantity.ExecuteScalar()); if (quantity > stock[i]) { row.Cells["quantity"].Value = stock[i]; } i++; } MySqlDataAdapter getDID = new MySqlDataAdapter("select Distinct Max(DeliveryID) from DeliveryNote;", cnn); DataTable dt2 = new DataTable(); if (status.Equals("FIN")) { btnGen.Enabled = false; lbDID.Text = ""; MySqlDataAdapter getDeliveryID = new MySqlDataAdapter("Select DeliveryID from DeliveryNote WHERE DesID = '" + iId + "';", cnn); DataTable dt3 = new DataTable(); getDeliveryID.Fill(dt3); foreach (DataRow dr in dt3.Rows) { lbDID.Text += Convert.ToString(dr[0]) + ", "; } } else { String did; getDID.Fill(dt2); did = dt2.Rows[0][0].ToString(); if (did.Equals("")) { did = "0"; } did = Regex.Match(did, @"\d+").Value; lbDID.Text = "D" + (Int32.Parse(did) + 1).ToString().PadLeft(7, '0'); } MySqlDataAdapter getRest = new MySqlDataAdapter("Select RestName, RestAddress From PurchaseRequest pr, Restaurant r where RequestNo = '" + rno + "' and pr.restNo=r.restNo;", cnn); DataTable restInfo = new DataTable(); getRest.Fill(restInfo); numQty.Maximum = 0; lbRName.Text = restInfo.Rows[0][0].ToString(); lbAddress.AppendText(restInfo.Rows[0][1].ToString()); lbCreationDate.Text = today.ToString("yyyy-MM-dd"); lbStatus.Text = status; lbDesId.Text = iId; lbRNo.Text = rno; cnn.Close(); btnUpdate.Enabled = false; }