Esempio n. 1
0
        public static DataSet getfieldAreaTopValue(int id)
        {
            string sql = "GetFieldAreaTopValue";
            ParameterCollection par = new ParameterCollection();
            par.Add("@Id", id.ToString());

            return SQLDatabaseManager.ExecuteDataSet1(sql, par);

        }
 private void BuildCommand(IConfigurationElement parametersSection, ParameterCollection parameters)
 {
     parameters.Clear();
     foreach (IConfigurationElement parameterElement in parametersSection.Elements.Values)
     {
         Parameter commandParameter = new Parameter();
         foreach (IConfigurationElement propertyElement in parameterElement.Elements.Values)
         {
             ReflectionServices.SetValue(commandParameter, propertyElement.GetAttributeReference("name").Value.ToString(), propertyElement.GetAttributeReference("value").Value);
         }
         parameters.Add(commandParameter);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// myself:不用异常处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchButton1_Click(object sender, EventArgs e)
        {
            //try
            //{
            if (SearchByXH.Text != "")
            {
                querry += "and [XH]= @XH";
            }
            if (SearchByNickName.Text != "")
            {
                querry += "and [User_NickName]=@UNN";
            }
            if (SearchByName.Text != "")
            {
                querry += "and [XM]=@XM";
            }
            if (SearchByQQ.Text != "")
            {
                querry += "and [User_QQ]=@UQ";
            }
            if (DropXY.SelectedValue != null)
            {
                querry += "and [YXSMC]=@XY";
            }
            if (DropZY.SelectedValue != null)
            {
                querry += "and [ZYMC]=@ZY";
            }
            //}
            //catch
            //{
            //    Context.Response.Write("<script>alert('出错了!')</script>");
            //}
            ParameterCollection co = new ParameterCollection();
            co.Add("@XH", SearchByXH.Text);
            co.Add("@UNN", SearchByNickName.Text);
            co.Add("@XM", SearchByName.Text);
            co.Add("@UQ", SearchByQQ.Text);
            co.Add("@XY", DropXY.SelectedValue);
            co.Add("@ZY", DropZY.SelectedValue);

            Source1.SelectCommand = querry;
            Repeater1.DataSource = Source1;
            Repeater1.DataBind();
        }
Esempio n. 4
0
        private static void ApplyParameterCollection(Row row, ParameterCollection parameters, string prefix)
        {
            if (string.IsNullOrEmpty(prefix))
                prefix = "{0}";
            foreach (RowCell cell in row.Cells)
            {
                string value = null;
                if (cell.Value != null)
                    value = cell.Value.ToString();

                if (parameters[cell.CellId] == null)
                    parameters.Add(cell.CellId, row.Columns[cell.CellId].DataType, value);
                else
                    parameters[cell.CellId].DefaultValue = value;

                if (parameters[String.Format("@" + prefix, cell.CellId)] == null)
                    parameters.Add(String.Format("@" + prefix, cell.CellId), row.Columns[cell.CellId].DataType, value);
                else
                    parameters[String.Format("@" + prefix, cell.CellId)].DefaultValue = value;
            }
        }
 private void OnOkButtonClick(object sender, EventArgs e)
 {
     ICollection dataSource = (ICollection) this._parametersDataGridView.DataSource;
     ParameterCollection parameters = new ParameterCollection();
     foreach (ParameterItem item in dataSource)
     {
         if (item.DbType == DbType.Object)
         {
             parameters.Add(new Parameter(item.Name, item.Type, item.DefaultValue));
         }
         else
         {
             parameters.Add(new Parameter(item.Name, item.DbType, item.DefaultValue));
         }
     }
     if (this._sqlDataSourceDesigner.RefreshSchema(new DesignerDataConnection(string.Empty, this._providerName, this._connectionString), this._selectCommand, this._selectCommandType, parameters, false))
     {
         base.DialogResult = DialogResult.OK;
         base.Close();
     }
 }
 private void SetParameters(ParameterCollection original, ParameterCollection newParams)
 {
     original.Clear();
     foreach (Parameter parameter in newParams)
     {
         original.Add(parameter);
     }
 }
 internal void CloneParameters(ParameterCollection originalParameters, ParameterCollection newParameters)
 {
     foreach (ICloneable parameter in originalParameters)
     {
         Parameter clone = (Parameter)parameter.Clone();
         RegisterClone(parameter, clone);
         newParameters.Add(clone);
     }
 }
Esempio n. 8
0
 private static void MoveParameters(ParameterCollection source, ParameterCollection target)
 {
     foreach (Parameter p in source)
     {
         target.Add(p);
     }
     source.Clear();
 }
 private void OnOkButtonClick(object sender, EventArgs e)
 {
     ParameterCollection parameters = new ParameterCollection();
     foreach (ParameterItem item in this._parameterItems)
     {
         if (item.Parameter.DbType == DbType.Object)
         {
             parameters.Add(new Parameter(item.Parameter.Name, item.Parameter.Type, item.Parameter.DefaultValue));
         }
         else
         {
             parameters.Add(new Parameter(item.Parameter.Name, item.Parameter.DbType, item.Parameter.DefaultValue));
         }
     }
     try
     {
         parameters.GetValues(null, null);
     }
     catch (Exception exception)
     {
         UIServiceHelper.ShowError(base.ServiceProvider, exception, System.Design.SR.GetString("SqlDataSourceParameterValueEditorForm_InvalidParameter"));
         return;
     }
     base.DialogResult = DialogResult.OK;
     base.Close();
 }
 internal static void MergeParameters(ParameterCollection parameters, MethodInfo methodInfo, System.Type dataObjectType)
 {
     Parameter[] parameterArray = new Parameter[parameters.Count];
     parameters.CopyTo(parameterArray, 0);
     parameters.Clear();
     if ((methodInfo != null) && (dataObjectType == null))
     {
         foreach (ParameterInfo info in methodInfo.GetParameters())
         {
             Parameter parameter = CreateMergedParameter(info, parameterArray);
             if (parameters[parameter.Name] == null)
             {
                 parameters.Add(parameter);
             }
         }
     }
 }
Esempio n. 11
0
 private void @__BuildControl__control2(System.Web.UI.WebControls.ParameterCollection @__ctrl)
 {
     global::System.Web.UI.WebControls.ControlParameter @__ctrl1;
     @__ctrl1 = this.@__BuildControl__control3();
     @__ctrl.Add(@__ctrl1);
 }
 public override void RefreshSchema(bool preferSilent)
 {
     try
     {
         this.SuppressDataSourceEvents();
         bool flag = false;
         IServiceProvider site = this.SqlDataSource.Site;
         if (!this.CanRefreshSchema)
         {
             if (!preferSilent)
             {
                 UIServiceHelper.ShowError(site, System.Design.SR.GetString("SqlDataSourceDesigner_RefreshSchemaRequiresSettings"));
             }
         }
         else
         {
             IDataSourceViewSchema schema = this.GetView("DefaultView").Schema;
             bool flag2 = false;
             if (schema == null)
             {
                 this._forceSchemaRetrieval = true;
                 schema = this.GetView("DefaultView").Schema;
                 this._forceSchemaRetrieval = false;
                 flag2 = true;
             }
             DesignerDataConnection connection = new DesignerDataConnection(string.Empty, this.ProviderName, this.ConnectionString);
             if (preferSilent)
             {
                 flag = this.RefreshSchema(connection, this.SelectCommand, this.SqlDataSource.SelectCommandType, this.SqlDataSource.SelectParameters, true);
             }
             else
             {
                 Parameter[] parameterArray = this.InferParameterNames(connection, this.SelectCommand, this.SqlDataSource.SelectCommandType);
                 if (parameterArray == null)
                 {
                     return;
                 }
                 ParameterCollection parameters = new ParameterCollection();
                 ParameterCollection parameters2 = new ParameterCollection();
                 foreach (ICloneable cloneable in this.SqlDataSource.SelectParameters)
                 {
                     parameters2.Add((Parameter) cloneable.Clone());
                 }
                 foreach (Parameter parameter in parameterArray)
                 {
                     if ((parameter.Direction == ParameterDirection.Input) || (parameter.Direction == ParameterDirection.InputOutput))
                     {
                         Parameter parameter2 = parameters2[parameter.Name];
                         if (parameter2 != null)
                         {
                             parameter.DefaultValue = parameter2.DefaultValue;
                             if ((parameter.DbType == DbType.Object) && (parameter.Type == TypeCode.Empty))
                             {
                                 parameter.DbType = parameter2.DbType;
                                 parameter.Type = parameter2.Type;
                             }
                             parameters2.Remove(parameter2);
                         }
                         parameters.Add(parameter);
                     }
                 }
                 if (parameters.Count > 0)
                 {
                     SqlDataSourceRefreshSchemaForm form = new SqlDataSourceRefreshSchemaForm(site, this, parameters);
                     flag = UIServiceHelper.ShowDialog(site, form) == DialogResult.OK;
                 }
                 else
                 {
                     flag = this.RefreshSchema(connection, this.SelectCommand, this.SqlDataSource.SelectCommandType, parameters, false);
                 }
             }
             if (flag)
             {
                 IDataSourceViewSchema schema2 = this.GetView("DefaultView").Schema;
                 if (flag2 && DataSourceDesigner.ViewSchemasEquivalent(schema, schema2))
                 {
                     this.OnDataSourceChanged(EventArgs.Empty);
                 }
                 else if (!DataSourceDesigner.ViewSchemasEquivalent(schema, schema2))
                 {
                     this.OnSchemaRefreshed(EventArgs.Empty);
                 }
             }
         }
     }
     finally
     {
         this.ResumeDataSourceEvents();
     }
 }
 private void OnTestQueryButtonClick(object sender, EventArgs e)
 {
     ParameterCollection parameters = new ParameterCollection();
     foreach (Parameter parameter in this._selectQuery.Parameters)
     {
         if (parameter.DbType == DbType.Object)
         {
             parameters.Add(new Parameter(parameter.Name, parameter.Type, parameter.DefaultValue));
         }
         else
         {
             parameters.Add(new Parameter(parameter.Name, parameter.DbType, parameter.DefaultValue));
         }
     }
     if (parameters.Count > 0)
     {
         SqlDataSourceParameterValueEditorForm form = new SqlDataSourceParameterValueEditorForm(base.ServiceProvider, parameters);
         if (UIServiceHelper.ShowDialog(base.ServiceProvider, form) == DialogResult.Cancel)
         {
             return;
         }
     }
     this._resultsGridView.DataSource = null;
     DbCommand command = null;
     Cursor current = Cursor.Current;
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         DbProviderFactory dbProviderFactory = SqlDataSourceDesigner.GetDbProviderFactory(this._dataConnection.ProviderName);
         DbConnection designTimeConnection = null;
         try
         {
             designTimeConnection = SqlDataSourceDesigner.GetDesignTimeConnection(base.ServiceProvider, this._dataConnection);
         }
         catch (Exception exception)
         {
             if (designTimeConnection == null)
             {
                 UIServiceHelper.ShowError(base.ServiceProvider, exception, System.Design.SR.GetString("SqlDataSourceSummaryPanel_CouldNotCreateConnection"));
                 return;
             }
         }
         if (designTimeConnection == null)
         {
             UIServiceHelper.ShowError(base.ServiceProvider, System.Design.SR.GetString("SqlDataSourceSummaryPanel_CouldNotCreateConnection"));
         }
         else
         {
             command = this._sqlDataSourceDesigner.BuildSelectCommand(dbProviderFactory, designTimeConnection, this._selectQuery.Command, parameters, this._selectQuery.CommandType);
             DbDataAdapter adapter = SqlDataSourceDesigner.CreateDataAdapter(dbProviderFactory, command);
             adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
             DataSet dataSet = new DataSet();
             adapter.Fill(dataSet);
             if (dataSet.Tables.Count == 0)
             {
                 UIServiceHelper.ShowError(base.ServiceProvider, System.Design.SR.GetString("SqlDataSourceSummaryPanel_CannotExecuteQueryNoTables"));
             }
             else
             {
                 this._resultsGridView.DataSource = dataSet.Tables[0];
                 foreach (DataGridViewColumn column in this._resultsGridView.Columns)
                 {
                     column.SortMode = DataGridViewColumnSortMode.NotSortable;
                 }
                 this._resultsGridView.AutoResizeColumnHeadersHeight();
                 this._resultsGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
             }
         }
     }
     catch (Exception exception2)
     {
         UIServiceHelper.ShowError(base.ServiceProvider, exception2, System.Design.SR.GetString("SqlDataSourceSummaryPanel_CannotExecuteQuery"));
     }
     finally
     {
         if ((command != null) && (command.Connection.State == ConnectionState.Open))
         {
             command.Connection.Close();
         }
         Cursor.Current = current;
     }
 }
 protected internal override void OnComplete()
 {
     PropertyDescriptor descriptor;
     SqlDataSource component = (SqlDataSource) this._sqlDataSourceDesigner.Component;
     if (component.DeleteCommand != this._deleteQuery.Command)
     {
         descriptor = TypeDescriptor.GetProperties(component)["DeleteCommand"];
         descriptor.SetValue(component, this._deleteQuery.Command);
     }
     if (component.DeleteCommandType != this._deleteQuery.CommandType)
     {
         descriptor = TypeDescriptor.GetProperties(component)["DeleteCommandType"];
         descriptor.SetValue(component, this._deleteQuery.CommandType);
     }
     if (component.InsertCommand != this._insertQuery.Command)
     {
         descriptor = TypeDescriptor.GetProperties(component)["InsertCommand"];
         descriptor.SetValue(component, this._insertQuery.Command);
     }
     if (component.InsertCommandType != this._insertQuery.CommandType)
     {
         descriptor = TypeDescriptor.GetProperties(component)["InsertCommandType"];
         descriptor.SetValue(component, this._insertQuery.CommandType);
     }
     if (component.SelectCommand != this._selectQuery.Command)
     {
         descriptor = TypeDescriptor.GetProperties(component)["SelectCommand"];
         descriptor.SetValue(component, this._selectQuery.Command);
     }
     if (component.SelectCommandType != this._selectQuery.CommandType)
     {
         descriptor = TypeDescriptor.GetProperties(component)["SelectCommandType"];
         descriptor.SetValue(component, this._selectQuery.CommandType);
     }
     if (component.UpdateCommand != this._updateQuery.Command)
     {
         descriptor = TypeDescriptor.GetProperties(component)["UpdateCommand"];
         descriptor.SetValue(component, this._updateQuery.Command);
     }
     if (component.UpdateCommandType != this._updateQuery.CommandType)
     {
         TypeDescriptor.GetProperties(component)["UpdateCommandType"].SetValue(component, this._updateQuery.CommandType);
     }
     this._sqlDataSourceDesigner.CopyList(this._selectQuery.Parameters, component.SelectParameters);
     this._sqlDataSourceDesigner.CopyList(this._insertQuery.Parameters, component.InsertParameters);
     this._sqlDataSourceDesigner.CopyList(this._updateQuery.Parameters, component.UpdateParameters);
     this._sqlDataSourceDesigner.CopyList(this._deleteQuery.Parameters, component.DeleteParameters);
     ParameterCollection parameters = new ParameterCollection();
     foreach (Parameter parameter in this._selectQuery.Parameters)
     {
         parameters.Add(parameter);
     }
     this._sqlDataSourceDesigner.RefreshSchema(this._dataConnection, this._selectQuery.Command, this._selectQuery.CommandType, parameters, true);
 }