private void btnAdd_Click(object sender, EventArgs e) { cData data = new cData(); if (data.AddWarning(staffno, dtp.Value, txtDesc.Text)) { MessageBox.Show("Warning Added", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
private void frmDetails_Load(object sender, EventArgs e) { data_proxy = new cData(); btnEdit.Enabled = false; btnSave.Enabled = false; lvNames.View = View.Details; lvNames.Columns.Add(new ColumnHeader()); lvNames.Columns.Add(new ColumnHeader()); lvNames.Columns[0].Text = "Staff No"; lvNames.Columns[0].Width = lvNames.Width * 3 / 10; lvNames.Columns[1].Text = "Staff No"; lvNames.Columns[1].Width = (lvNames.Width * 7 / 10) - 3; data_proxy.GetList(lvNames); data_proxy.LoadBase(cbBase); //enable disable groupBox1.Enabled = false; groupBox3.Enabled = false; groupBox5.Enabled = false; groupBox6.Enabled = false; //warning list lvWarn.View = View.Details; lvWarn.Columns.Add(new ColumnHeader()); lvWarn.Columns.Add(new ColumnHeader()); lvWarn.Columns[0].Text = "Warning Date"; lvWarn.Columns[0].Width = lvWarn.Width * 3 / 10; lvWarn.Columns[1].Text = "Description"; lvWarn.Columns[1].Width = (lvNames.Width * 7 / 10) - 3; }
private void btnSave_Click(object sender, EventArgs e) { foreach (Control c in groupBox1.Controls) { if (c.GetType().ToString() == "System.Windows.Forms.TextBox") { if (c.Text == "") { MessageBox.Show("Please Enter Data in the required fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } foreach (Control c in groupBox3.Controls) { if (c.GetType().ToString() == "System.Windows.Forms.TextBox") { if (c.Text == "") { MessageBox.Show("Please Enter Data in the required fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } string[] info = new string[20]; info[0] = txtStaffNo.Text; info[1] = txtIDNo.Text; info[2] = txtFName.Text; info[3] = txtMName.Text; info[4] = txtSName.Text; info[5] = dtpDob.Value.ToShortDateString(); info[6] = dtpEmp.Value.ToShortDateString(); info[7] = txtDist.Text; info[8] = txtDiv.Text; info[9] = txtLoc.Text; info[10] = txtSubLoc.Text; info[11] = txtRes.Text; info[12] = ""; info[13] = txtFirstRef.Text; info[14] = txtFirstRefRel.Text; info[15] = txtSecRef.Text; info[16] = txtSecRefRel.Text; info[17] = cbBase.Text; info[18] = txtMobile.Text; info[19] = txtEmail.Text; cData data = new cData(); if (data.AddNew(info)) { MessageBox.Show("New Record Added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); groupBox1.Enabled = false; groupBox3.Enabled = false; groupBox5.Enabled = false; groupBox6.Enabled = false; data_proxy.GetList(lvNames); } }