private void btnSave_Click(object sender, EventArgs e) { if (check()) { MessageBox.Show("Please complete required data!", "System Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { int prov = DBAccess.get_cmb_data(txtProv.Text, "sp_get_cmb_province", "prov_id"); int reg = DBAccess.get_cmb_data(txtReg.Text, "sp_get_cmb_region", "region_id"); int host_sub = DBAccess.get_cmb_data(txtOrgtypeSub.Text, "sp_get_cmb_host_org_type_sub", "host_org_type_sub_id"); int host_main = DBAccess.get_cmb_data(txtOrgtype.Text, "sp_get_cmb_host_org_type_main", "host_org_type_id"); hstOrg = new hostOrg( txtName.Text.Trim(), txtHeadName.Text.Trim(), txtPosition.Text.Trim(), txtAddressNo.Text.Trim(), txtAddressStreet.Text.Trim(), txtAddressCity.Text.Trim(), txtTelNumber1.Text.Trim(), txtTelNumber2.Text.Trim(), txtFaxNumber.Text.Trim(), txtEmail.Text.Trim(), txtWebsite.Text.Trim(), rtbMandate.Text, prov.ToString(), reg.ToString(), host_sub.ToString(), host_main.ToString() ); DBAccess.insert_host_org(hstOrg); logs = new auditTrail(frm_login.UserName, "Added a LPI"); DBAccess.insert_logs(logs); MessageBox.Show("Successfully Added!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void dgv_hstorg_DoubleClick(object sender, EventArgs e) { int i = dgv_hstorg.CurrentRow.Index; string id = dgv_hstorg.Rows[i].Cells["ID"].Value.ToString(); frm_HstOrgnztnInfo h = new frm_HstOrgnztnInfo(); h.txtclear(); hst_org = DBAccess.get_host_org(int.Parse(id)); if (hst_org != null) { try { h.txtid.Text = hst_org.Host_id.ToString(); h.txtName.Text = hst_org.Host_org_name; h.txtHeadName.Text = hst_org.Head_name; h.txtPosition.Text = hst_org.Title; h.txtAddressNo.Text = hst_org.Address1; h.txtAddressStreet.Text = hst_org.Address2; h.txtAddressCity.Text = hst_org.City; h.txtTelNumber1.Text = hst_org.Tel_number1; h.txtTelNumber2.Text = hst_org.Tel_number2; h.txtFaxNumber.Text = hst_org.Fax_number; h.txtEmail.Text = hst_org.Email; h.txtWebsite.Text = hst_org.Website; h.rtbMandate.Text = hst_org.Mandate; h.cmbProvince.Text = hst_org.Province; h.cmbOrgtypeSub.Text = hst_org.Host_org_type_sub; h.cmbOrgtype.Text = hst_org.Host_org_type; h.cmbRegion.Text = hst_org.Region; h.h_sub = hst_org.Host_org_type_sub; h.txtOrgtypeSub.Text = hst_org.Host_org_type_sub; h.txtOrgtype.Text = hst_org.Host_org_type; h.txtReg.Text = hst_org.Region; h.txtProv.Text = hst_org.Province; h.prov = hst_org.Province; h.btnSave.Visible = false; h.txtid.Enabled = false; h.ShowDialog(); } catch (IndexOutOfRangeException ex) { MessageBox.Show(ex.Message, "Incomplete Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please click refresh!"); } }