示例#1
0
        private void frmSearch_Load(object sender, EventArgs e)
        {
            try
            {
                if (dt.Rows.Count == 0)
                {
                    MessageView.ShowWarningMsg("No record(s) found");
                    this.Dispose();
                }
                dgvSearch.DataSource = dt;

                // hide extra fields

                for (int i = 0; i < dgvSearch.Columns.Count; i++)
                {
                    if (maxColumnCount < (i + 1))
                    {
                        dgvSearch.Columns[i].Visible = false;
                    }
                }

                Utility.SetDatagridViewRow(dgvSearch);

                if (firstColWidth > 0 && dgvSearch.Columns.Count > 0)
                {
                    dgvSearch.Columns[0].Width = firstColWidth;
                }
            }
            catch (Exception ex)
            {
                MessageView.ExceptionError(ex);
            }
        }
示例#2
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     try
     {
         this.DialogResult = DialogResult.Cancel;
         this.Dispose();
     }
     catch (Exception ex)
     {
         MessageView.ExceptionError(ex);
     }
 }
示例#3
0
 private void dgvSearch_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.KeyData == Keys.Return)
         {
             selectRow(dgvSearch.CurrentRow.Index);
         }
     }
     catch (Exception ex)
     {
         MessageView.ExceptionError(ex);
     }
 }
示例#4
0
        //private void dgvSearch_Sorted(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        new ApplicationSettings().SetColuredGridsRows(ref dgvSearch);
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageView.ExceptionError(ex);
        //    }
        //}


        private void dgvSearch_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex > -1)
                {
                    selectRow(e.RowIndex);
                }
            }
            catch (Exception ex)
            {
                MessageView.ExceptionError(ex);
            }
        }
示例#5
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvSearch.SelectedRows.Count > 0)
         {
             selectRow(dgvSearch.CurrentRow.Index);
         }
         else
         {
             this.DialogResult = DialogResult.Cancel;
             MessageView.ShowWarningMsg("Please select a row");
         }
     }
     catch (Exception ex)
     {
         MessageView.ExceptionError(ex);
     }
 }
示例#6
0
        private void Init(DataTable dt, string text)
        {
            InitializeComponent();

            if (maxColumnCount > 10)
            {
                dgvSearch.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
            }
            else
            {
                dgvSearch.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            }

            try
            {
                //ned to remove
                // ds = new GeneralFunctions("dcb", "dcb").GetTestData();
                ///ned to remove
                ///
                int colCnt = dt.Columns.Count;

                selectedRowData = new object[colCnt];

                if (colCnt > 0)
                {
                    for (int i = 0; i < colCnt; i++)
                    {
                        string actText = dt.Columns[i].Caption;
                        selectedRowData[i] = actText;
                        string newText = getFormatedColumnName(actText);
                        dt.Columns[i].ColumnName = newText;
                    }
                }

                this.dt    = dt;
                this.Text += " _ " + text;
            }
            catch (Exception ex)
            {
                MessageView.ExceptionError(ex);
            }
        }
示例#7
0
        private void selectRow(int index)
        {
            try
            {
                this.DialogResult = DialogResult.OK;

                //set selected data
                Hashtable htbl = new Hashtable();
                for (int i = 0; i < selectedRowData.Length; i++)
                {
                    htbl.Add(selectedRowData[i].ToString(), dgvSearch[i, index].Value);
                }

                DataRowValues = htbl;
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageView.ExceptionError(ex);
            }
        }