| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 | using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace FPER{    public partial class frmModalPositionCode : Form    {        public frmModalPositionCode()        {            InitializeComponent();        }        MDIParent mdi = null;        public void setMdiParent(MDIParent mdi)        {            try            {                this.mdi = mdi;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private SearchCodeVo searchCode;        public SearchCodeVo SearchCode { get { return this.searchCode; } set { this.searchCode = value; } }        private void frmModalPositionCode_Load(object sender, EventArgs e)        {            try            {                dataGridView1.Rows.Clear();                if (searchCode.CodeType != null)                {                    if (searchCode.CodeType.Length < 1) searchCode.CodeType = null;                }                if (searchCode.CodeName != null)                {                    if (searchCode.CodeName.Length < 1) searchCode.CodeName = null;                }                txtSearchKey.Text = searchCode.CodeName;                get_Data(null);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)        {            try            {                //셀 더블클릭시                if (e.ColumnIndex >= 0 && e.RowIndex >= 0)                {                    string CodeValue = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();                    string CodeName = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();                    this.searchCode.Code = CodeValue;                    this.searchCode.CodeName = CodeName;                    this.searchCode.SearchOK = true;                    this.Close();                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnOK_Click(object sender, EventArgs e)        {            try            {                String searchKey = txtSearchKey.Text;                //if (searchKey.Length < 1)                //{                //    MessageBox.Show("먼저 검색할 단어를 입력하세요.", Application.ProductName);                //    return;                //}                if (searchKey.Equals("")) searchKey = null;                get_Data(searchKey);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void get_Data(String SearchKey)        {            dataGridView1.Rows.Clear();            try            {                DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DataTable dtable = dacDeviceConfig.Position_Code_Modal_Select(SearchKey);                if (dtable.Rows.Count > 0)                {                    foreach (DataRow dr in dtable.Rows)                    {                        dataGridView1.Rows.Add(dr["POSITION_CODE"].ToString(), dr["POSITION_NAME"].ToString());                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void txtSearchKey_KeyDown(object sender, KeyEventArgs e)        {            try            {                //엔터키 입력시 확인버튼으로 포커스                if (e.KeyCode == Keys.Enter)                {                    btnOK_Click(btnOK, EventArgs.Empty);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnCancel_Click(object sender, EventArgs e)        {            try            {                this.Close();            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnSaveOK_Click(object sender, EventArgs e)        {            try            {                if (dataGridView1.SelectedRows.Count > 0)                {                    DataGridViewRow row = dataGridView1.SelectedRows[0];                    string CodeValue = row.Cells[0].Value.ToString();                    string CodeName = row.Cells[1].Value.ToString();                    this.searchCode.Code = CodeValue;                    this.searchCode.CodeName = CodeName;                    this.searchCode.SearchOK = true;                    this.Close();                }                else                {                    MessageBox.Show("선택된 코드가 없습니다.", Application.ProductName);                    return;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnPositionAdd_Click(object sender, EventArgs e)        {            try            {                this.Close();                this.mdi.ShowChildForm(new frmPositionCode());            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }    }}
 |