using PTMedicalInsurance.Forms.Setters.GetInsuCode; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PTMedicalInsurance.Forms.GetInsuCode { public delegate DataTable GetCodeDelegate( string args); public partial class CodeGetter : Form { public DataTable dt { get; set; } public string code { get; set; } public string name { get; set; } public event GetCodeDelegate GetCode; public CodeGetter() { InitializeComponent(); } public CodeGetter(string key) { InitializeComponent(); edt_SearchKey.Text = key; GridViewSetter gvdSetter = new GridViewSetter(); gvdSetter.SetAdmdvsData(dbAdmdvs); //Search(key); } public void Search(string sKey) { dbAdmdvs.DataSource = GetCode(sKey);; } private void SelectAdmIndex() { int iHis = dbAdmdvs.CurrentRow.Index; code = dbAdmdvs.Rows[iHis].Cells["Code"].Value.ToString(); name = dbAdmdvs.Rows[iHis].Cells["Name"].Value.ToString(); DialogResult = DialogResult.OK; } private void btnOk_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; SelectAdmIndex(); } private void dbAdmdvs_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { DialogResult = DialogResult.OK; SelectAdmIndex(); } private void edt_SearchKey_DoEnter(object sender, EventArgs e) { Search(edt_SearchKey.Text); } private void btnCancel_Click(object sender, EventArgs e) { Close(); } } }