private void btnSave_Click(object sender, EventArgs e) { try { if (lblerror1.Visible == true) { MessageBox.Show("Institution sub type is already in use!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtTitle.Text == string.Empty) { MessageBox.Show("Please complete the required data!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int host_main = DBAccess.get_cmb_data(txtOrgtype.Text, "sp_get_cmb_institution_Main", "host_org_type_id"); iSub = new institutionTypeSUB(host_main.ToString(), txtTitle.Text, chbisNGO.Checked ? 1 : 0); DBAccess.insert_institution_Sub(iSub); logs = new auditTrail(frm_login.UserName, "Added a Organization sub type"); DBAccess.insert_logs(logs); MessageBox.Show("Successfully Added!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); dgv_orgTypeSUB.DataSource = DBAccess.dataTableLoad("sp_load_institution_type_Sub"); btnUpdate.Visible = true; btnAdd.Visible = true; btnUpdate.Visible = true; btnSave.Visible = false; btnCancel.Visible = false; dgv_orgTypeSUB.Enabled = true; clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { if (txtID.Text == string.Empty || txtID.Text == "(Auto Generated)") { MessageBox.Show("Please select user to update!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtTitle.Text == string.Empty) { MessageBox.Show("Please input Institution Main type!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int host_main = DBAccess.get_cmb_data(txtOrgtype.Text, "sp_get_cmb_institution_Main", "host_org_type_id"); iSub = new institutionTypeSUB(int.Parse(txtID.Text), host_main.ToString(), txtTitle.Text, chbisNGO.Checked ? 1:0); DBAccess.update_institution_Sub(iSub); dgv_orgTypeSUB.DataSource = DBAccess.dataTableLoad("sp_load_institution_type_Sub"); logs = new auditTrail(frm_login.UserName, "Updated Organization sub type id " + txtID.Text); DBAccess.insert_logs(logs); MessageBox.Show("Successfully Updated!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } // clear(); }
private void dgv_orgTypeSUB_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int i = dgv_orgTypeSUB.CurrentRow.Index; int id = int.Parse(dgv_orgTypeSUB.Rows[i].Cells["ID"].Value.ToString()); iSub = DBAccess.get_institutionTypeSUB(id); if (iSub != null) { try { txtID.Text = iSub.Id.ToString(); txtTitle.Text = iSub.SubType; txtOrgtype.Text = iSub.MainType; cmbOrgtype.Text = iSub.MainType; if (iSub.IsNGO == 1) { chbisNGO.Checked = true; } else { chbisNGO.Checked = false; } txtTitle.Enabled = true; lblerror1.Visible = false; temp_name = txtTitle.Text.Trim(); } catch (IndexOutOfRangeException ex) { MessageBox.Show(ex.Message, "Incomplete Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Null"); } }