Пример #1
0
        public void Open()
        {
            JkDataSetList.Add(this);
            OnBeforeOpen();
            SqlDataAdapter DataAdapter = new SqlDataAdapter(CommandText, Connection.ConnectionString);

            try
            {
                try
                {
                    if (Parameters.Count > 0)
                    {
                        for (int i = 0; i <= Parameters.Count - 1; i++)
                        {
                            if (String.IsNullOrWhiteSpace(Parameters[i].Value))
                            {
                                DataAdapter.SelectCommand.Parameters.AddWithValue("@" + Parameters[i].Name, 0);
                            }
                            else
                            {
                                DataAdapter.SelectCommand.Parameters.AddWithValue("@" + Parameters[i].Name, Parameters[i].Value);
                            }
                        }
                    }

                    DataTable.Clear();
                    DataAdapter.Fill(DataTable);
                }
                finally
                {
                    DataAdapter.SelectCommand.Connection.Close();
                    DataAdapter.Dispose();
                    Active = true;
                }
            }
            catch (Exception ex)
            {
                new Exception("Object Name: " + this.Name + "\rError: " + ex.Message);
            }
        }
Пример #2
0
        private void JkDataGridView_EditModeChanged(object sender, EventArgs e)
        {
            foreach (DataGridViewColumn column in this.Columns)
            {
                if (this.Columns[column.Index] is DataGridViewComboBoxColumn)
                {
                    String           controlName = this.DataSet.Columns.Find(c => c.Name == this.Columns[column.Index].DataPropertyName).ControlName;
                    JkLookUpComboBox comboBox    = JkLookUpComboBoxList.FindByName(controlName);
                    JkDataSet        dataSet     = JkDataSetList.FindByName(comboBox.DataSet);

                    if (dataSet.Filtered &&
                        dataSet.Filter != null &&
                        this.EditMode != DataGridViewEditMode.EditProgrammatically &&
                        !String.IsNullOrWhiteSpace(dataSet.Filter))
                    {
                        ((this.Columns[column.Index] as DataGridViewComboBoxColumn).DataSource as DataTable).DefaultView.RowFilter = dataSet.Filter;
                    }
                    else
                    {
                        ((this.Columns[column.Index] as DataGridViewComboBoxColumn).DataSource as DataTable).DefaultView.RowFilter = String.Empty;
                    }
                }
            }
        }