Esempio n. 1
0
 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
 {
     GridViewReport.ClearColumnsFilter();
     if (RptTypeBindingSource.Current == null)
     {
         //fake query in order to create a link between the database table and the binding source
         RptTypeBindingSource.DataSource = from opt in context.RPTTYPE where opt.CODE == "KJM9" select opt;
         RptTypeBindingSource.AddNew();
         if (GridViewReport.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewReport.FocusedRowHandle = GridViewReport.RowCount - 1;
         }
         setValues();
         TextEditCode.Focus();
         setReadOnly(false);
         newRec = true;
         return;
     }
     TextEditCode.Focus();
     //bindingNavigatorPositionItem.Focus();  //trigger field leave event
     GridViewReport.CloseEditor();
     temp = newRec;
     if (checkForms())
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( RPTTYPE)RptTypeBindingSource.Current);
         }
         RptTypeBindingSource.AddNew();
         if (GridViewReport.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewReport.FocusedRowHandle = GridViewReport.RowCount - 1;
         }
         TextEditCode.Focus();
         setValues();
         setReadOnly(false);
         newRec = true;
     }
 }
Esempio n. 2
0
        private void executeQuery()
        {
            this.Cursor = Cursors.WaitCursor;
            string colName = GridViewReport.FocusedColumn.FieldName;
            string value   = String.Empty;

            if (!string.IsNullOrWhiteSpace(GridViewReport.GetFocusedDisplayText()))
            {
                value = GridViewReport.GetFocusedDisplayText();
            }
            if (!string.IsNullOrWhiteSpace(value))
            {
                string query   = String.Format("it.CODE like '{0}%'", GridViewReport.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE"));
                var    special = context.RPTTYPE.Where(query);

                if (!string.IsNullOrWhiteSpace(GridViewReport.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "DESC")))
                {
                    query   = String.Format("it.{0} like '{1}%'", "[DESC]", GridViewReport.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "DESC"));
                    special = special.Where(query);
                }
                int count = special.Count();
                if (count > 0)
                {
                    RptTypeBindingSource.DataSource = special;
                    GridViewReport.SetRowCellValue(GridControl.AutoFilterRowHandle, colName, value);
                    GridViewReport.FocusedRowHandle        = 0;
                    GridViewReport.FocusedColumn.FieldName = colName;
                }
                else
                {
                    MessageBox.Show("No records in database.");
                    GridViewReport.ClearColumnsFilter();
                }
            }
            this.Cursor = Cursors.Default;
        }