public void ShowData1(clsA blocka) { txtName.Text = blocka.Name; txtAddress.Text = blocka.Address; txtId.Text = blocka.Id.ToString(); txtPriority.Text = blocka.Priority.ToString(); txtMath.Text = blocka.Markm.ToString(); txtPhysicalA.Text = blocka.Markp.ToString(); txtChemistryA.Text = blocka.Markc.ToString(); }
void BtnDeleteClick(object sender, EventArgs e) { try { clsB current = (clsB)source[dgshow.CurrentRowIndex]; source.RemoveAt(dgshow.CurrentRowIndex); }catch { } try { clsA current1 = (clsA)source1[dgshow.CurrentRowIndex]; source1.RemoveAt(dgshow.CurrentRowIndex); }catch { } try { clsC current2 = (clsC)source2[dgshow.CurrentRowIndex]; source2.RemoveAt(dgshow.CurrentRowIndex); }catch { } }
void BtnAddClick(object sender, EventArgs e) { for (int i = 0; i < A.Count; i++) { if (txtId.Text == A[i].Id.ToString()) { MessageBox.Show("This id has used! // Please input valid ID. Thanks"); ClearData(); } } for (int i = 0; i < B.Count; i++) { if (txtId.Text == B[i].Id.ToString()) { MessageBox.Show("This id has used! // Please input valid ID. Thanks"); ClearData(); } } for (int i = 0; i < C.Count; i++) { if (txtId.Text == C[i].Id.ToString()) { MessageBox.Show("This id has used! // Please input valid ID. Thanks"); ClearData(); } } if (txtAddress.Text == "" || txtPriority.Text == "" || txtName.Text == "" || txtId.Text == "" || txtId.Text.Length != 5) { ClearData(); } else { int scan = 0; if (rdbA.Checked == true) { scan = 1; } if (rdbB.Checked == true) { scan = 2; } if (rdbC.Checked == true) { scan = 3; } if (scan == 1) { if (txtMath.Text == "" || txtPhysicalA.Text == "" || txtPhysicalA.Text == "") { ClearData(); } else { dgshow.DataSource = source1; a.Name = txtName.Text; a.Id = int.Parse(txtId.Text); a.Address = txtAddress.Text; a.Priority = int.Parse(txtPriority.Text); a.Markc = double.Parse(txtChemistryA.Text); a.Markm = double.Parse(txtMath.Text); a.Markp = double.Parse(txtPhysicalA.Text); source1.Add(a); a = new clsA(); ClearData(); dgshow.Refresh(); } } if (scan == 2) { if (txtBiology.Text == "" || txtPhysicalB.Text == "" || txtChemistryB.Text == "") { ClearData(); } else { dgshow.DataSource = source; b.Name = txtName.Text; b.Id = int.Parse(txtId.Text); b.Address = txtAddress.Text; b.Priority = int.Parse(txtPriority.Text); b.Markb = double.Parse(txtBiology.Text); b.Markc = double.Parse(txtChemistryB.Text); b.Markp = double.Parse(txtPhysicalB.Text); source.Add(b); b = new clsB(); ClearData(); dgshow.Refresh(); } } if (scan == 3) { if (txtHistory.Text == "" || txtGeoraphy.Text == "" || txtLiterature.Text == "") { ClearData(); } else { dgshow.DataSource = source1; c.Name = txtName.Text; c.Id = int.Parse(txtId.Text); c.Address = txtAddress.Text; c.Priority = int.Parse(txtPriority.Text); c.Markh = double.Parse(txtHistory.Text); c.Markg = double.Parse(txtGeoraphy.Text); c.Markl = double.Parse(txtLiterature.Text); source2.Add(c); c = new clsC(); ClearData(); dgshow.Refresh(); } } } }