Esempio n. 1
0
        private void executeQuery()
        {
            this.Cursor = Cursors.WaitCursor;
            string colName = AdvBandedGridViewCarRate.FocusedColumn.FieldName;
            string value   = String.Empty;

            if (!string.IsNullOrWhiteSpace(AdvBandedGridViewCarRate.GetFocusedDisplayText()))
            {
                value = AdvBandedGridViewCarRate.GetFocusedDisplayText();
            }
            if (!string.IsNullOrWhiteSpace(value))
            {
                //string query = String.Format("it.{0} = {1}", "Inactive", false);
                string query   = String.Format("it.CAT like '{0}%'", AdvBandedGridViewCarRate.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CAT"));
                var    special = context.CARRATES.Where(query);

                if (!string.IsNullOrWhiteSpace(AdvBandedGridViewCarRate.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE")))
                {
                    query   = String.Format("it.{0} like '{1}%'", "CODE", AdvBandedGridViewCarRate.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE"));
                    special = special.Where(query);
                }
                if (!string.IsNullOrWhiteSpace(AdvBandedGridViewCarRate.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "OFF")))
                {
                    query   = String.Format("it.{0} like '{1}%'", "OFF", AdvBandedGridViewCarRate.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "OFF"));
                    special = special.Where(query);
                }
                if (!string.IsNullOrWhiteSpace(AdvBandedGridViewCarRate.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "START_DATE")))
                {
                    string validDate = AdvBandedGridViewCarRate.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "START_DATE");
                    string values    = validCheck.convertDate(validDate);
                    if (!string.IsNullOrWhiteSpace(values))
                    {
                        DateTime startDate = Convert.ToDateTime(values);
                        special = special.Where("it.START_DATE >= @date", new ObjectParameter("date", startDate));
                    }
                }
                int count = special.Count();
                if (count > 0)
                {
                    CarRateBindingSource.DataSource = special;
                    //AdvBandedGridViewCarRate.SetRowCellValue(GridControl.AutoFilterRowHandle, colName, value);
                    AdvBandedGridViewCarRate.FocusedRowHandle = 0;
                    AdvBandedGridViewCarRate.ClearColumnsFilter();
                }
                else
                {
                    MessageBox.Show("No records in database.");
                    AdvBandedGridViewCarRate.ClearColumnsFilter();
                }
            }
            this.Cursor = Cursors.Default;
        }
Esempio n. 2
0
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            AdvBandedGridViewCarRate.ClearColumnsFilter();
            if (CarRateBindingSource.Current == null)
            {
                //fake query in order to create a link between the database table and the binding source
                CarRateBindingSource.DataSource = from opt in context.CARRATES where opt.CODE == "KJM9" select opt;
                CarRateBindingSource.AddNew();
                if (AdvBandedGridViewCarRate.FocusedRowHandle == GridControl.AutoFilterRowHandle)
                {
                    AdvBandedGridViewCarRate.FocusedRowHandle = AdvBandedGridViewCarRate.RowCount - 1;
                }
                setValues();
                ImageComboBoxEditCode.Focus();
                setReadOnly(false);
                sTART_DATEDateEdit.Properties.ReadOnly = false;
                newRec = true;
                return;
            }
            ImageComboBoxEditCode.Focus();
            // bindingNavigatorPositionItem.Focus();  //trigger field leave event

            temp = newRec;
            if (checkForms())
            {
                if (!temp)
                {
                    context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( CARRATES)CarRateBindingSource.Current);
                }
                CarRateBindingSource.AddNew();
                if (AdvBandedGridViewCarRate.FocusedRowHandle == GridControl.AutoFilterRowHandle)
                {
                    AdvBandedGridViewCarRate.FocusedRowHandle = AdvBandedGridViewCarRate.RowCount - 1;
                }
                setValues();
                ImageComboBoxEditCode.Focus();

                setReadOnly(false);
                sTART_DATEDateEdit.Properties.ReadOnly = false;
                newRec = true;
            }
        }