//Retrieves the Complaint object with the given reference number from the database public Complaint retComplaint(Water_Board_Management.Database d,String rn) { if (!(d.hasEntry(rn))) return null; String[] det = d.getRow(rn); Complaint temp = new Complaint(Int32.Parse(det[0]), Int32.Parse(det[1]), det[2], det[3], det[4], det[6]); if (det[5].Equals("True")) { temp.complete(); temp.setComplete(det[7]); } temp.setProgress(det[8]); temp.setPriority(Int32.Parse(det[9])); return temp; }
//Stores a Complaint object in the database public void storeComplaint(Water_Board_Management.Database d,Complaint cmp) { Water_Board_Management.ComplaintRow cr = new Water_Board_Management.ComplaintRow(cmp.getReference(), cmp.getAccount(), cmp.getType(), cmp.getSub(), cmp.getAdd(), cmp.isCompleted(), cmp.getSubmit(), cmp.getComplete(), cmp.getProgress(), cmp.getPriority()); d.insert(cr); }
private void subm1_Click(object sender, EventArgs e) { int tp; if (String.IsNullOrWhiteSpace(accNumBx.Text)) { MessageBox.Show("Please enter the account number", "No account number", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if ((!(int.TryParse(accNumBx.Text, out tp))) || (accNumBx.Text.Contains(".")) || (accNumBx.Text.Length < 7)||(!db3.hasEntry(accNumBx.Text))) { MessageBox.Show("Please enter a valid account number", "Invalid account number", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if ((maintypeCmb.SelectedIndex == 0) && (String.IsNullOrWhiteSpace(addInfoBx.Text))) { MessageBox.Show("Please specify the leakage location", "Info Missing", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if ((maintypeCmb.SelectedIndex == 3) && (String.IsNullOrWhiteSpace(addInfoBx.Text))) { MessageBox.Show("Please enter more information", "Info Missing", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if ((maintypeCmb.SelectedIndex == 2) && (subtypeCmb.SelectedIndex == 2) && (String.IsNullOrWhiteSpace(addInfoBx.Text))) { MessageBox.Show("Please specify a reason for suspicion", "Info Missing", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int r = genRefNo(0); refNo.Text = "Reference Number : "; for (int i = 1; i <= (5 - r.ToString().Length); i++) { refNo.Text += "0"; } refNo.Text += r; refNo.Visible = true; Complaint temp; String day = DateTime.Today.Year.ToString() + "-" + DateTime.Today.Month.ToString() + "-" + DateTime.Today.Day.ToString(); if (maintypeCmb.SelectedIndex == 3) { temp = new Complaint(r, Int32.Parse(accNumBx.Text), maintypeCmb.SelectedItem.ToString(), "", addInfoBx.Text, day); } else { if (String.IsNullOrWhiteSpace(addInfoBx.Text)) { temp = new Complaint(r, Int32.Parse(accNumBx.Text), maintypeCmb.SelectedItem.ToString(), subtypeCmb.SelectedItem.ToString(), day); } else { temp = new Complaint(r, Int32.Parse(accNumBx.Text), maintypeCmb.SelectedItem.ToString(), subtypeCmb.SelectedItem.ToString(), addInfoBx.Text, day); } } cdb.storeComplaint(db, temp); } }