private void cboPreSupp_SelectedIndexChanged(object sender, EventArgs e) { if (cboPreSupp.SelectedIndex == -1) { return; } //display Stock details // txtSuppID.Text = preSupplier.getSuppID().ToString("000"); //display Stock details txtSuppID.Text = cboPreSupp.Text.Substring(0, 3); DataSet ds = new DataSet(); ds = CD.getSuppCDs(ds, Convert.ToInt32(txtSuppID.Text)); string testData = ""; for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { Font font1 = new Font(FontFamily.GenericMonospace.Name, 9); cbopreordCD.Font = font1; //testData = ds.Tables[0].Rows[i][0].ToString().PadLeft(5, '0')+" "+ ds.Tables[0].Rows[i][1].ToString().Trim().PadRight(30)+"X"; //MessageBox.Show(testData); //cbopreordCD.Items.Add(testData); cbopreordCD.Items.Add(String.Format("{0:00000} {1,-30} {2,5}", ds.Tables[0].Rows[i][0], ds.Tables[0].Rows[i][1].ToString(), ds.Tables[0].Rows[i][5].ToString())); //cbopreordCD.Items.Add(String.Format(ds.Tables[0].Rows[i][0].ToString().PadLeft(5, '0') + " " + ds.Tables[0].Rows[i][1].ToString().PadRight(30, ' ') + " " + String.Format(ds.Tables[0].Rows[i][5].ToString(), "000.00"))); } Supplier preSupplier = new Supplier(); preSupplier.getSupp(Convert.ToInt32(cboPreSupp.Text.Substring(0, 3))); if (preSupplier.getSuppID().Equals(0)) { MessageBox.Show("No details found", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } grpPreorderCD.Visible = true; }
private void loadCDItems() { DS = new DataSet(); DS = CD.getAvailableCDS1(DS); cboupdCD.Items.Clear(); for (int i = 0; i < DS.Tables["ss"].Rows.Count; i++) { cboupdCD.Items.Add(DS.Tables[0].Rows[i][0].ToString().PadLeft(3, '0') + " " + DS.Tables[0].Rows[i][1].ToString()); } DataSet ds = new DataSet(); ds = Supplier.getAllActiveSuppliers(ds); //load suppliers for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cboSuppliers.Items.Add(ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0') + " " + ds.Tables[0].Rows[i][1].ToString()); } }
private void cbopreordCD_SelectedIndexChanged(object sender, EventArgs e) { if (cbopreordCD.SelectedIndex == -1) { return; } CD preOrdCD = new CD(); //preOrdCD.getCD(Convert.ToInt32(cbopreordCD.Text.Substring(0, 3))); preOrdCD.getCD(Convert.ToInt32(cbopreordCD.Text.Substring(0, 5))); if (preOrdCD.getCDID().Equals(0)) { MessageBox.Show("No details found", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } cbopreordCD.SelectedItem = preOrdCD.getCDID().ToString("00000"); }
private void loadCDItems() { DS = new DataSet(); //DS = CD.getAllCDsSuppliedbySupp(DS); cdid = new CD(); cbopreordCD.Items.Clear(); for (int i = 0; i < DS.Tables["ss"].Rows.Count; i++) { cbopreordCD.Items.Add(DS.Tables[0].Rows[i][0].ToString().PadLeft(3, '0') + " " + DS.Tables[0].Rows[i][1].ToString()); } int theCDID = cdid.getCDID(); cbopreordCD.SelectedIndex = 0; while (!cbopreordCD.Text.Substring(0, 5).Equals(theCDID.ToString("00000"))) { cbopreordCD.SelectedIndex++; } }
private void cboPreSupp_SelectedIndexChanged(object sender, EventArgs e) { if (cboPreSupp.SelectedIndex == -1) { return; } //display Stock details // txtSuppID.Text = preSupplier.getSuppID().ToString("000"); //display Stock details txtSuppID.Text = cboPreSupp.Text.Substring(0, 3); DataSet ds = new DataSet(); ds = CD.getSuppCDs(ds, Convert.ToInt32(txtSuppID.Text)); for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cbopreordCD.Items.Add(ds.Tables[0].Rows[i][0].ToString().PadLeft(5, '0') + " " + ds.Tables[0].Rows[i][1].ToString().PadRight(30, ' ') + " " + String.Format(ds.Tables[0].Rows[i][5].ToString(), "000.00")); } Supplier preSupplier = new Supplier(); preSupplier.getSupp(Convert.ToInt32(cboPreSupp.Text.Substring(0, 3))); if (preSupplier.getSuppID().Equals(0)) { MessageBox.Show("No details found", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } grpPreorderCD.Visible = true; }
private void btnUInsert_Click(object sender, EventArgs e) { decimal n; int num; if (cboupdCD.Text.Equals("")) { MessageBox.Show("No CD chosen! A CD must be picked!", "CD Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtUAlbum.Text.Equals("")) { MessageBox.Show("No album entered! This album must be entered!", "Album Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUAlbum.Focus(); return; } else if (txtUArtist.Text.Equals("")) { MessageBox.Show("No artist entered! Please type in an artist!", "Artist Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUArtist.Focus(); return; } else if (!decimal.TryParse(txtUCostPrice.Text, out n)) { if (n <= 0) { MessageBox.Show("Cost is invalid! This cost field must be re-entered!", "Cost Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } txtUCostPrice.Focus(); return; } else if (!int.TryParse(txtuQty.Text, out num)) { if (num <= 0) { MessageBox.Show("Quality is invalid! This quality field must be re-entered!", "Quality Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } txtuQty.Focus(); return; } char availablity = 'a'; CD cd = new CD(); cd.setCDID(Convert.ToInt32(txtCDID.Text)); cd.setAlbumName(txtUAlbum.Text); cd.setArtist(txtUArtist.Text); cd.setYr(Convert.ToInt32(txtYr.Text)); cd.setArtLabel(txtUArtistLbl.Text); cd.setCostPrice(Convert.ToDecimal(txtUCostPrice.Text)); cd.setQty(Convert.ToInt32(txtuQty.Text)); cd.setSuppId(Convert.ToInt32(cboSuppliers.Text.Substring(0, 3))); //cd.setAvailability('a'); cd.setAvailability(availablity); cd.updCD(); //Save Data in Supplier File MessageBox.Show("CD: " + cboupdCD.GetItemText(cboupdCD.SelectedItem) + "\n\nCD_ID: " + txtCDID.Text + "\nAlbum: " + txtUAlbum.Text + "\nArtist: " + txtUArtist.Text + "\nYear Released: " + txtYr.Text + "\nArtist Label: " + txtUArtistLbl.Text + "\nCost Price: €" + txtUCostPrice.Text + "\nQuality: " + txtuQty.Text + "\nSuppliers: " + cboSuppliers.GetItemText(cboSuppliers.SelectedItem) + "\nAvailability: " + availablity, "Updated CD Details: ", MessageBoxButtons.OK, MessageBoxIcon.Information); //Display confirmation message MessageBox.Show("CD has now been updated!", "CD Updated", MessageBoxButtons.OK, MessageBoxIcon.Information); loadCDItems(); // cboupdCD.SelectedIndex = -1; grpUCD.Visible = false; txtCDID.Clear(); txtUAlbum.Clear(); txtUArtist.Clear(); txtYr.Clear(); txtUArtistLbl.Clear(); txtUCostPrice.Clear(); txtuQty.Clear(); cboSuppliers.SelectedIndex = -1; }
private void btnInsertCD_Click(object sender, EventArgs e) { decimal number; int num; if (txtAlbum.Text.Equals("")) { MessageBox.Show("No album entered! This album must be entered!", "Album Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtAlbum.Focus(); return; } else if (txtArtist.Text.Equals("")) { MessageBox.Show("No artist entered! Please type in an artist!", "Artist Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtArtist.Focus(); return; } else if (!decimal.TryParse(txtCost.Text, out number)) { if (number <= 0) { MessageBox.Show("Cost is invalid! This cost field must be re-entered!", "Cost Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } txtCost.Focus(); return; } else if (!int.TryParse(txtQty.Text, out num)) { if (num <= 0) { MessageBox.Show("Quality is invalid! This quality field must be re-entered!", "Quality Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } txtQty.Focus(); return; } //Set Default Values String availability = "a"; CD cd = new CD(); cd.setCDID(Convert.ToInt32(txtCDID.Text)); cd.setAlbumName(txtAlbum.Text); cd.setArtist(txtArtist.Text); cd.setYr(Convert.ToInt32(chkYr.GetItemText(chkYr.SelectedItem))); cd.setArtLabel(GetRadioButtonText(grpArtistLbl)); cd.setCostPrice(Convert.ToDecimal(txtCost.Text)); cd.setQty(Convert.ToInt32(txtQty.Text)); cd.setSuppId(Convert.ToInt32(cboSuppliers.Text.Substring(0, 3))); cd.setAvailability('a'); cd.regCD(); //Save Data in CD File MessageBox.Show("CD ID; " + txtCDID.Text + "\nAlbum: " + txtAlbum.Text + "\nArtist: " + txtArtist.Text + "\nYear Released: " + chkYr.GetItemText(chkYr.SelectedItem) + "\nArtist Label: " + GetRadioButtonText(grpArtistLbl) + "\nCost Price: €" + txtCost.Text + "\nQuality: " + txtQty.Text + "\nSupplier: " + cboSuppliers.GetItemText(cboSuppliers.SelectedItem) + "\nAvailabilty: " + availability, "CD Details: ", MessageBoxButtons.OK, MessageBoxIcon.Information); //Display confirmation message MessageBox.Show("CD has now been added!", "CD Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); //Reset UI txtCDID.Text = CD.nextCD().ToString("00000"); //txtCDID.Text = "00002"; txtAlbum.Focus(); txtAlbum.Clear(); txtArtist.Clear(); chkYr.ClearSelected(); txtCost.Clear(); txtQty.Clear(); cboSuppliers.SelectedIndex = -1; foreach (int i in chkYr.CheckedIndices) { chkYr.SetItemCheckState(i, CheckState.Unchecked); } return; }