Inheritance: System.ComponentModel.Component, IDbCommand, IDisposable
Exemplo n.º 1
0
 /// <summary>
 /// 加载参数
 /// </summary>
 public static void BuildDBParameter(Database db, DbCommand dbCommand, params SqlParameter[] cmdParms)
 {
     foreach (SqlParameter sp in cmdParms)
     {
         db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType,sp.Value);
     }
 }
 public void AssignParameters(DbCommand command, object[] parameterValues)
 {
     InitializeParameters(command);
     db.SetParameterValue(command, "@CD_EMPRESA", parameterValues[0]);
     db.SetParameterValue(command, "@CD_SEQECF", parameterValues[1]);
     db.SetParameterValue(command, "@DT_EMI", parameterValues[2]);
 }
Exemplo n.º 3
0
        public virtual DbParameter AddParameter(DbCommand dm, string name, DbType dbType, int size,
            ParameterDirection direction, bool nullable, byte precision, byte scale, string sourceColumn,
            DataRowVersion sourceVersion, object value)
        {
            ////if (dbType == DbType.String)
            ////    throw new Exception("请不要使用DbType.String进行数据库查询!");

            if (CheckInjectAttackForSp(dm, value))
                throw new Exception("输入的部分内容可能对系统稳定性造成影响,操作已停止![" + value + "]");

            DbParameter param = this.ProviderFactory.CreateParameter();
            if (param != null)
            {
                param.ParameterName = name;
                param.DbType = dbType;
                param.Size = size;
                param.Value = value ?? DBNull.Value;
                param.Direction = direction;
                param.IsNullable = nullable;
                param.SourceColumn = sourceColumn;
                param.SourceVersion = sourceVersion;
                dm.Parameters.Add(param);
            }
            return param;
        }
        private void SetDynamicFilterParameterValues(DbCommand command, DbContext context)
        {
            if ((command == null) || (command.Parameters.Count == 0) || (context == null))
                return;

            context.SetSqlParameters(command);
        }
Exemplo n.º 5
0
 internal DisposingDbDataReader(DbCommand command)
 {
     if (command == null)
         throw new ArgumentNullException("command");
     this.command = command;
     reader = command.ExecuteReader(CommandBehavior.CloseConnection);
 }
Exemplo n.º 6
0
 public GlimpseDbDataReader(DbDataReader dataReader, DbCommand command, Guid connectionId, Guid commandId)
 {
     InnerDataReader = dataReader;
     InnerCommand = command;        
     ConnectionId = connectionId;
     CommandId = commandId; 
 }
 private void InitializeParameters(DbCommand command)
 {
     if (!command.Parameters.Contains("@EmployeeId"))
     {
         _db.AddInParameter(command, "@EmployeeId", DbType.Int32);
     }
 }
Exemplo n.º 8
0
    // executes a command and returns the results as a DataTable object
    public static DataTable ExecuteSelectCommand(DbCommand command)
    {
        // The DataTable to be returned
        DataTable table;
        // Execute the command making sure the connection gets closed in the end
        try
        {
            // Open the data connection
            command.Connection.Open();
            // Execute the command and save the results in a DataTable
            DbDataReader reader = command.ExecuteReader();
            table = new DataTable();
            table.Load(reader);

            // Close the reader
            reader.Close();
        }
        catch (Exception ex)
        {
            Utilities.LogError(ex);
            throw;
        }
        finally
        {
            // Close the connection
            command.Connection.Close();
        }
        return table;
    }
Exemplo n.º 9
0
 public static DataTable ReadTable(DbCommand cmd)
 {
     DataTable dt = new DataTable();
     DbDataReader reader = null;
     try
     {
         reader = cmd.ExecuteReader();
         int fieldc = reader.FieldCount;
         for (int i = 0; i < fieldc; i++)
         {
             DataColumn dc = new DataColumn(reader.GetName(i), reader.GetFieldType(i));
             dt.Columns.Add(dc);
         }
         while (reader.Read())
         {
             DataRow dr = dt.NewRow();
             for (int i = 0; i < fieldc; i++)
             {
                 dr[i] = reader[i];
             }
             dt.Rows.Add(dr);
         }
         return dt;
     }
     finally
     {
         if (reader != null) reader.Close();
     }
 }
Exemplo n.º 10
0
		public SqlDataSourceStatusEventArgs (DbCommand command, int rowsAffected, Exception exception)
		{
			this.command = command;
			this.rowsAffected = rowsAffected;
			this.exception = exception;
			this.exceptionHandled = false;
		}
Exemplo n.º 11
0
        /// <summary>
        ///     Returns a DataSet (best used for multiple tables in the result set)
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// <see cref=">http://msdn.microsoft.com/en-us/library/fks3666w%28VS.80%29.aspx" />
        public static DataSet ExecuteMultipleTableSelectCommand(DbCommand command)
        {
            using (command)
            {
                var factory = DbProviderFactories.GetFactory(DataBaseConfigs.DbProviderName);

                using (var adapter = factory.CreateDataAdapter())
                {
                    if (adapter == null) return null;

                    adapter.SelectCommand = command;

                    using (var ds = new DataSet())
                    {
                        try
                        {
                            adapter.Fill(ds);
                        }
                        catch (Exception ex)
                        {
                            Utilities.LogError(ex);

                            return null;
                        }

                        command.Connection.Close();
                        return ds;
                    }
                }
            }
        }
Exemplo n.º 12
0
 public static void AddWithValue(ref DbCommand command, string parameterName, object parameterValue)
 {
     var parameter = command.CreateParameter();
     parameter.ParameterName = parameterName;
     parameter.Value = parameterValue;
     command.Parameters.Add(parameter);
 }
 private void InitializeParameters(DbCommand command)
 {
     if (!command.Parameters.Contains("@CD_CLIFOR"))
     {
         db.AddInParameter(command, "@CD_CLIFOR", DbType.String);
     }
 }
 // execute a select command and return a single result as a string
 public static string ExecuteScalar(DbCommand command)
 {
     // The value to be returned
     string value = "";
     // Execute the command making sure the connection gets closed in the end
     try
     {
       // Open the connection of the command
       command.Connection.Open();
       // Execute the command and get the number of affected rows
       value = command.ExecuteScalar().ToString();
     }
     catch (Exception ex)
     {
       // Log eventual errors and rethrow them
       //Utilities.LogError(ex);
       throw ex;
     }
     finally
     {
       // Close the connection
       command.Connection.Close();
     }
     // return the result
     return value;
 }
 // execute an update, delete, or insert command
 // and return the number of affected rows
 public static int ExecuteNonQuery(DbCommand command)
 {
     // The number of affected rows
     int affectedRows = -1;
     // Execute the command making sure the connection gets closed in the end
     try
     {
       // Open the connection of the command
       command.Connection.Open();
       // Execute the command and get the number of affected rows
       affectedRows = command.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
       // Log eventual errors and rethrow them
       //Utilities.LogError(ex);
       throw ex;
     }
     finally
     {
       // Close the connection
       command.Connection.Close();
     }
     // return the number of affected rows
     return affectedRows;
 }
Exemplo n.º 16
0
        public static string GetSqlFromDbCommand(DbCommand dbCommand)
        {
            string strSql = dbCommand.CommandText;

            foreach (DbParameter dp in dbCommand.Parameters)
            {
                string strReplace = string.Empty;

                if (dp.Value == DBNull.Value)
                {
                    strReplace = "NULL";
                }
                else if (dp.DbType == DbType.Int32)
                {
                    strReplace = string.Format("{0}", dp.Value);
                }
                else
                {
                    strReplace = string.Format("'{0}'", dp.Value);
                }

                strSql = strSql.Replace(PARAMETER_NAME_PREFIX_AT + dp.ParameterName, strReplace);
                strSql = strSql.Replace(PARAMETER_NAME_PREFIX_COLON + dp.ParameterName, strReplace);
            }

            return strSql;
        }
Exemplo n.º 17
0
 internal TableManager(string tableName)
 {
     try
     {
         _da = TableManager._DbProviderFactory.CreateDataAdapter();
         _cmd = TableManager._DbProviderFactory.CreateCommand();
         DbCommandBuilder cb =
            TableManager._DbProviderFactory.CreateCommandBuilder();
         cb.QuotePrefix = "[";
         cb.QuoteSuffix = "]";
         _cmd.Connection = TableManager.Connection;
         cb.ConflictOption = ConflictOption.OverwriteChanges;
         cb.DataAdapter = _da;
         _dt = new DataTable();
         _temp = new DataTable();
         _dt.TableName = _temp.TableName = tableName;
         _cmd.CommandText = "Select * from " + Table.TableName;
         _da.SelectCommand = _cmd;
         _da.InsertCommand = cb.GetInsertCommand();
         _da.DeleteCommand = cb.GetDeleteCommand();
         _da.UpdateCommand = cb.GetUpdateCommand();
         Recharge("1 = 2");
     }
     catch { GlobalErrorCode = 13; }
     if (GlobalErrorCode == 13)
         MessageBox.Show("ОШИБКА");
 }
 public LoggingCommandWrapper(DbCommand dbCommand, ILogger logger)
 {
     Contract.Requires(dbCommand != null, nameof(dbCommand) + " is null.");
     Contract.Requires(logger != null, nameof(logger) + " is null.");
     _WrappedDbCommand = dbCommand;
     _Logger = logger;
 }
Exemplo n.º 19
0
        private DataTable GetReportData(DbCommand cmd, ArrayList parameterList)
        {
            db.AddInParameter(cmd, "p_patchDateS", DbType.String, parameterList[0]);
            db.AddInParameter(cmd, "p_patchDateE", DbType.String, parameterList[1]);
            db.AddInParameter(cmd, "p_signDate_S", DbType.String, parameterList[2]);
            db.AddInParameter(cmd, "p_signDate_E", DbType.String, parameterList[3]);
            db.AddInParameter(cmd, "p_acDate_S", DbType.String, parameterList[4]);
            db.AddInParameter(cmd, "p_acDate_E", DbType.String, parameterList[5]);
            db.AddInParameter(cmd, "p_groupS", DbType.String, parameterList[6]);
            db.AddInParameter(cmd, "p_groupE", DbType.String, parameterList[7]);
            db.AddInParameter(cmd, "p_payRfno", DbType.String, parameterList[8]);
            db.AddInParameter(cmd, "p_rfno", DbType.String, parameterList[9]);
            db.AddInParameter(cmd, "p_profit_S", DbType.String, parameterList[10]);
            db.AddInParameter(cmd, "p_profit_E", DbType.String, parameterList[11]);
            db.AddInParameter(cmd, "p_store_S", DbType.String, parameterList[12]);
            db.AddInParameter(cmd, "p_store_E", DbType.String, parameterList[13]);
            db.AddInParameter(cmd, "p_acUID", DbType.String, parameterList[14]);
            db.AddInParameter(cmd, "p_rootNo", DbType.String, parameterList[15]);
            db.AddInParameter(cmd, "p_item", DbType.String, parameterList[16]);
            db.AddInParameter(cmd, "p_periodS", DbType.String, parameterList[17]);
            db.AddInParameter(cmd, "p_periodE", DbType.String, parameterList[18]);
            db.AddInParameter(cmd, "p_checkReasonS", DbType.String, parameterList[19]);
            db.AddInParameter(cmd, "p_checkReasonE", DbType.String, parameterList[20]);
            db.AddInParameter(cmd, "p_descTypeS", DbType.String, parameterList[21]);
            db.AddInParameter(cmd, "p_descTypeE", DbType.String, parameterList[22]);
            db.AddInParameter(cmd, "p_diffTimes", DbType.String, parameterList[23]);
            db.AddInParameter(cmd, "p_diffAmount", DbType.String, parameterList[24]);
            db.AddInParameter(cmd, "p_diffSource", DbType.String, parameterList[25]);
            db.AddInParameter(cmd, "p_op1", DbType.String, ConvertOperator(parameterList[26].ToString()));
            db.AddInParameter(cmd, "p_op2", DbType.String, ConvertOperator(parameterList[27].ToString()));

            DataTable dt = db.ExecuteDataSet(cmd).Tables[0];
            return dt;
        }
Exemplo n.º 20
0
 protected virtual void AddParametersFromCache(DbCommand command, Database database)
 {
     foreach (IDataParameter parameter in this.cache.GetCachedParameterSet(database.ConnectionString, command))
     {
         command.Parameters.Add(parameter);
     }
 }
 private void setupDbCommand( DbCommand dbCmd, DatabaseInfo databaseInfo )
 {
     dbCmd.CommandText = sproc;
     dbCmd.CommandType = CommandType.StoredProcedure;
     foreach( var p in parameters )
         dbCmd.Parameters.Add( p.GetAdoDotNetParameter( databaseInfo ) );
 }
Exemplo n.º 22
0
 public void CreateAndCacheDbCommandParameters(string sqlCommandText,
                                               DbCommand command,
                                               string[] paramNames,
                                               DbType[] paramDbTypes,
                                               object[] paramValues) 
 {
     lock (lockObject)
     {
         if (this.ParameterCache.IsCache(sqlCommandText))
         {
             this.ParameterCache.AddParametersFromCache(sqlCommandText, command, paramDbTypes, paramValues);
         }
         else
         {
             if (this.ParameterCache.IsCache(sqlCommandText))
             {
                 this.ParameterCache.AddParametersFromCache(sqlCommandText, command, paramDbTypes, paramValues);
             }
             else
             {
                 this.ParameterCache.CreateAndCacheParameters(sqlCommandText, command, paramNames, paramDbTypes, paramValues);
             }
         }
     }
 }
Exemplo n.º 23
0
 private static IDataParameter[] CreateParameterCopy(DbCommand command)
 {
     IDataParameterCollection parameters = command.Parameters;
     IDataParameter[] array = new IDataParameter[parameters.Count];
     parameters.CopyTo(array, 0);
     return CachingMechanism.CloneParameters(array);
 }
Exemplo n.º 24
0
        public Manager(String fileName)
        {
            localization = new System.ComponentModel.ComponentResourceManager(typeof(WorkerTimeStrings));
            this.fileName = fileName;
            if (File.Exists(fileName)) {
                this.sqlConnection = new SQLiteConnection("Data Source=" + fileName );
                this.sqlCommand = this.sqlConnection.CreateCommand();
                sqlConnection.Open();
            } else {
                this.sqlConnection = new SQLiteConnection("Data Source=" + fileName);
                this.sqlCommand = this.sqlConnection.CreateCommand();
                sqlConnection.Open();

                ExecuteNonQuery("CREATE TABLE Tracks ([ID] INTEGER PRIMARY KEY AUTOINCREMENT, [ProjectID] INTEGER, [ActivityID] INTEGER, [Start] DATETIME, [End] DATETIME, [Duration] INTEGER)");
                ExecuteNonQuery("CREATE TABLE Projects ([ID] INTEGER PRIMARY KEY AUTOINCREMENT, [Name] TEXT)");
                ExecuteNonQuery("CREATE TABLE Activity ([ID] INTEGER PRIMARY KEY AUTOINCREMENT, [Name] TEXT, [ProjectID] INTEGER)");

                if (MessageBox.Show(localization.GetString("String10"), localization.GetString("String3"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes )
                {
                    ExecuteNonQuery("INSERT INTO Projects (Name) VALUES ('" + localization.GetString("String12") + " 1')");
                    ExecuteNonQuery("INSERT INTO Projects (Name) VALUES ('" + localization.GetString("String12") + " 2')");
                    ExecuteNonQuery("INSERT INTO Projects (Name) VALUES ('" + localization.GetString("String12") + " 3')");
                    ExecuteNonQuery("INSERT INTO Activity (Name,ProjectID) VALUES ('" + localization.GetString("String13") + " 1',1)");
                    ExecuteNonQuery("INSERT INTO Activity (Name,ProjectID) VALUES ('" + localization.GetString("String13") + " 2',1)");
                    ExecuteNonQuery("INSERT INTO Activity (Name,ProjectID) VALUES ('" + localization.GetString("String13") + " 3',1)");
                    ExecuteNonQuery("INSERT INTO Activity (Name,ProjectID) VALUES ('" + localization.GetString("String13") + " 1',2)");
                    ExecuteNonQuery("INSERT INTO Activity (Name,ProjectID) VALUES ('" + localization.GetString("String13") + " 2',2)");
                    ExecuteNonQuery("INSERT INTO Activity (Name,ProjectID) VALUES ('" + localization.GetString("String13") + " 3',2)");
                }
            }

            Update1();
        }
Exemplo n.º 25
0
 public override void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
 {
     if (command.Parameters.Count > 0 && command.Parameters[0].Value.ToString() == "Throw")
     {
         interceptionContext.Exception = new DataException("Exception Test");
     }
 }
Exemplo n.º 26
0
 /// <summary>
 /// 为储存过程加载输出变量参数
 /// </summary>
 /// <param name="db">database</param>
 /// <param name="dbCommand">db command</param>
 /// <param name="cmdParms">参数数组</param>
 public static void BuildDBParameterForReturnValue(Database db, DbCommand dbCommand, params IDataParameter[] cmdParms)
 {
     foreach (SqlParameter sp in cmdParms)
     {
         db.AddParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Size, ParameterDirection.Output, false, 0, 0, sp.SourceColumn, DataRowVersion.Current, DBNull.Value);
     }
 }
Exemplo n.º 27
0
 /// <summary>
 /// Get a command for stored procedure
 /// </summary>
 /// <param name="pStoredProcedureName"></param>
 /// <returns></returns>
 public DbCommand CreateCommand(string pStoredProcedureName)
 {
     Command = CreateCommand();
     Command.CommandType = CommandType.StoredProcedure;
     Command.CommandText = pStoredProcedureName;
     return Command;
 }
 public void BindFixtureSymbols(Symbols symbols, DbCommand dc)
 {
     foreach (String paramName in ExtractParamNames(dc.CommandText))
     {
         AddInput(dc, paramName, symbols.GetValueOrDefault(paramName, null));
     }
 }
Exemplo n.º 29
0
        /// <summary>
        /// Tracks when 'command' is started.
        /// </summary>
        public void ExecuteStartImpl(DbCommand command, ExecuteType type)
        {
            var id = Tuple.Create((object)command, type);
            var sqlTiming = new SqlTiming(command, type, Profiler);

            _inProgress[id] = sqlTiming;
        }
Exemplo n.º 30
0
    protected void ProductDetailsViewSqlDataSource_Inserted(object sender, SqlDataSourceStatusEventArgs e)
    {
        System.Data.Common.DbCommand command = e.Command;

        ProductDetailsViewSqlDataSource.SelectParameters["ProductID"].DefaultValue = command.Parameters["@ProductID"].Value.ToString();

        ProductGridView.DataBind();
        ProductDetailsView.DataBind();
    }
Exemplo n.º 31
0
    protected void DesignationDataSource_OnInserted(Object sender, SqlDataSourceStatusEventArgs e)
    {
        System.Data.Common.DbCommand command = e.Command;

        GridView GridView1Code = UpdatePanel2.FindControl("GridView1") as GridView;

        GridView1Code.DataBind();
        ScriptManager.RegisterClientScriptBlock(GridView1Code, this.GetType(), "AlertMsg", "<script language='javascript'>$('html, body').animate({ scrollTop: $(document).height() }, 1000);</script>", false);
        SetDateRangesWhichCannotBeUsed();

        UpdatePanel2.Update();
    }
Exemplo n.º 32
0
    protected void SqlDataSourceFAQ_Inserted(object sender, SqlDataSourceStatusEventArgs e)
    {
        System.Data.Common.DbCommand command = e.Command;
        string IdFAQ = command.Parameters["@IdFAQ"].Value.ToString();

        SqlDataSourceFAQReference.InsertParameters["IdQA"].DefaultValue = IdFAQ;
        GridView GridView1 = (GridView)DetailsView1.Rows[2].FindControl("GridView1");

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            GridViewRow  Row           = GridView1.Rows[i];
            DropDownList DropDownList1 = ((DropDownList)Row.Cells[0].FindControl("DropDownList1"));
            if (DropDownList1.SelectedValue == "0")
            {
                continue;
            }
            Label Label1_ = ((Label)Row.Cells[0].FindControl("Label1_"));
            SqlDataSourceFAQReference.InsertParameters["IdReference"].DefaultValue     = Label1_.Text;
            SqlDataSourceFAQReference.InsertParameters["IdReferenceData"].DefaultValue = DropDownList1.SelectedValue;
            SqlDataSourceFAQReference.Insert();
        }

        ListView ListView1 = (ListView)DetailsView1.Rows[3].FindControl("ListView1");

        SqlDataSourceFAQTags.InsertParameters["IdQA"].DefaultValue = IdFAQ;
        for (int i = 0; i < ListView1.Items.Count; i++)
        {
            ListViewItem Item      = ListView1.Items[i];
            CheckBox     CheckBox1 = (CheckBox)Item.FindControl("CheckBox1");
            Label        IDLabel   = ((Label)Item.FindControl("IDLabel"));
            if (!CheckBox1.Checked)
            {
                continue;
            }
            SqlDataSourceFAQTags.InsertParameters["IdTag"].DefaultValue = IDLabel.Text;
            SqlDataSourceFAQTags.Insert();
        }
    }
Exemplo n.º 33
0
    protected void SqlDataSourceScenario_Inserted(object sender, SqlDataSourceStatusEventArgs e)
    {
        System.Data.Common.DbCommand command = e.Command;
        string IdScenario = command.Parameters["@IdScenario"].Value.ToString();

        SqlDataSourceScenarioTypeClient.InsertParameters["IdScenario"].DefaultValue = IdScenario;

        ListView ListView1 = (ListView)DetailsView1.Rows[3].FindControl("ListView1");


        for (int i = 0; i < ListView1.Items.Count; i++)
        {
            ListViewItem Item         = ListView1.Items[i];
            CheckBox     CheckBox1    = (CheckBox)Item.FindControl("ActiveCheckBox");
            HiddenField  HiddenField1 = ((HiddenField)Item.FindControl("HiddenField1"));
            if (!CheckBox1.Checked)
            {
                continue;
            }
            SqlDataSourceScenarioTypeClient.InsertParameters["IdClientType"].DefaultValue = HiddenField1.Value;
            SqlDataSourceScenarioTypeClient.Insert();
        }

        TextBox TextBox3 = (TextBox)DetailsView1.Rows[4].FindControl("TextBox3");

        String[] Buttons = TextBox3.Text.ToString().Split(new Char [] { ',' });
        for (int i = 0; i < Buttons.Length; i++)
        {
            string ButtonIVR = Buttons[i].Trim();
            if (ButtonIVR != "")
            {
                SqlDataSourceIVR.InsertParameters["IdScenario"].DefaultValue = IdScenario;
                SqlDataSourceIVR.InsertParameters["Button"].DefaultValue     = ButtonIVR;
                SqlDataSourceIVR.Insert();
            }
        }
    }
 public override DbCommandDefinition CreateCommandDefinition(DbCommand prototype)
 {
     return(new GlimpseDbCommandDefinition(InnerProviderServices.CreateCommandDefinition(prototype)));
 }
Exemplo n.º 35
0
 private int GetAllMenusCount()
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("select count(*) from vshop_Menu");
     return(1 + Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand)));
 }
Exemplo n.º 36
0
        private bool ExecuteTest()
        {
            this.errorMsgs = new System.Collections.Generic.List <string>();
            System.Data.Common.DbTransaction dbTransaction = null;
            System.Data.Common.DbConnection  dbConnection  = null;
            string item;

            try
            {
                if (this.ValidateConnectionStrings(out item))
                {
                    System.Data.Common.DbConnection dbConnection2;
                    dbConnection = (dbConnection2 = new System.Data.SqlClient.SqlConnection(this.GetConnectionString()));
                    try
                    {
                        dbConnection.Open();
                        System.Data.Common.DbCommand dbCommand = dbConnection.CreateCommand();
                        dbTransaction         = dbConnection.BeginTransaction();
                        dbCommand.Connection  = dbConnection;
                        dbCommand.Transaction = dbTransaction;
                        dbCommand.CommandText = "CREATE TABLE installTest(Test bit NULL)";
                        dbCommand.ExecuteNonQuery();
                        dbCommand.CommandText = "DROP TABLE installTest";
                        dbCommand.ExecuteNonQuery();
                        dbTransaction.Commit();
                        dbConnection.Close();
                        goto IL_94;
                    }
                    finally
                    {
                        if (dbConnection2 != null)
                        {
                            ((System.IDisposable)dbConnection2).Dispose();
                        }
                    }
                }
                this.errorMsgs.Add(item);
                IL_94 :;
            }
            catch (System.Exception ex)
            {
                this.errorMsgs.Add(ex.Message);
                if (dbTransaction != null)
                {
                    try
                    {
                        dbTransaction.Rollback();
                    }
                    catch (System.Exception ex2)
                    {
                        this.errorMsgs.Add(ex2.Message);
                    }
                }
                if (dbConnection != null && dbConnection.State != System.Data.ConnectionState.Closed)
                {
                    dbConnection.Close();
                    dbConnection.Dispose();
                }
            }
            string folderPath = base.Request.MapPath(Globals.ApplicationPath + "/config/test.txt");

            if (!Install.TestFolder(folderPath, out item))
            {
                this.errorMsgs.Add(item);
            }
            try
            {
                Configuration configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(base.Request.ApplicationPath);
                if (configuration.ConnectionStrings.ConnectionStrings["HidistroSqlServer"].ConnectionString == "none")
                {
                    configuration.ConnectionStrings.ConnectionStrings["HidistroSqlServer"].ConnectionString = "required";
                }
                else
                {
                    configuration.ConnectionStrings.ConnectionStrings["HidistroSqlServer"].ConnectionString = "none";
                }
                configuration.Save();
            }
            catch (System.Exception ex3)
            {
                this.errorMsgs.Add(ex3.Message);
            }
            folderPath = base.Request.MapPath(Globals.ApplicationPath + "/storage/test.txt");
            if (!Install.TestFolder(folderPath, out item))
            {
                this.errorMsgs.Add(item);
            }
            return(this.errorMsgs.Count == 0);
        }
Exemplo n.º 37
0
 protected override void DeriveParameters(System.Data.Common.DbCommand discoveryCommand)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 38
0
 public override System.Data.DataSet GetVotes()
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT *, (SELECT ISNULL(SUM(ItemCount),0) FROM distro_VoteItems WHERE VoteId = distro_Votes.VoteId) AS VoteCounts FROM distro_Votes WHERE DistributorUserId=@DistributorUserId");
     this.database.AddInParameter(sqlStringCommand, "DistributorUserId", System.Data.DbType.Int32, HiContext.Current.User.UserId);
     return(this.database.ExecuteDataSet(sqlStringCommand));
 }
Exemplo n.º 39
0
 public override int SetVoteIsBackup(long voteId)
 {
     System.Data.Common.DbCommand storedProcCommand = this.database.GetStoredProcCommand("sub_Votes_IsBackup");
     this.database.AddInParameter(storedProcCommand, "VoteId", System.Data.DbType.Int64, voteId);
     return(this.database.ExecuteNonQuery(storedProcCommand));
 }
Exemplo n.º 40
0
 public override bool DeleteVoteItem(long voteId, System.Data.Common.DbTransaction dbTran)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE FROM distro_VoteItems WHERE VoteId = @VoteId");
     this.database.AddInParameter(sqlStringCommand, "VoteId", System.Data.DbType.Int64, voteId);
     return(this.database.ExecuteNonQuery(sqlStringCommand, dbTran) > 0);
 }
Exemplo n.º 41
0
 public override int GetVoteCounts(long voteId)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT ISNULL(SUM(ItemCount),0) FROM distro_VoteItems WHERE VoteId = @VoteId");
     this.database.AddInParameter(sqlStringCommand, "VoteId", System.Data.DbType.Int64, voteId);
     return((int)this.database.ExecuteScalar(sqlStringCommand));
 }
Exemplo n.º 42
0
 public override bool DistroHasDrawRequest()
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT COUNT(*) FROM Hishop_DistributorBalanceDrawRequest WHERE UserId=@UserId");
     this.database.AddInParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, HiContext.Current.User.UserId);
     return(Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand)) >= 1);
 }
Exemplo n.º 43
0
 public override void RemoveInpourRequest(string inpourId)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE FROM Hishop_DistributorInpourRequest WHERE InpourId = @InpourId");
     this.database.AddInParameter(sqlStringCommand, "InpourId", System.Data.DbType.String, inpourId);
     this.database.ExecuteNonQuery(sqlStringCommand);
 }
Exemplo n.º 44
0
 public override bool IsRecharge(string inpourId)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT COUNT(*) FROM Hishop_DistributorBalanceDetails WHERE InpourId = @InpourId");
     this.database.AddInParameter(sqlStringCommand, "InpourId", System.Data.DbType.String, inpourId);
     return((int)this.database.ExecuteScalar(sqlStringCommand) > 0);
 }
Exemplo n.º 45
0
 public override void DeleteSiteRequest()
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE FROM Hishop_SiteRequest WHERE UserId=@UserId");
     this.database.AddInParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, HiContext.Current.User.UserId);
     this.database.ExecuteNonQuery(sqlStringCommand);
 }
Exemplo n.º 46
0
 public override bool IsExitSiteUrl(string siteUrl)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT COUNT(*) FROM distro_Settings WHERE SiteUrl = @SiteUrl");
     this.database.AddInParameter(sqlStringCommand, "SiteUrl", System.Data.DbType.String, siteUrl);
     return((int)this.database.ExecuteScalar(sqlStringCommand) > 0);
 }
Exemplo n.º 47
0
 public override void SetDefalutMemberGrade(int gradeId)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_MemberGrades SET IsDefault = 0;UPDATE aspnet_MemberGrades SET IsDefault = 1 WHERE GradeId = @GradeId");
     this.database.AddInParameter(sqlStringCommand, "GradeId", System.Data.DbType.Int32, gradeId);
     this.database.ExecuteNonQuery(sqlStringCommand);
 }
Exemplo n.º 48
0
 public bool DeleteMenu(int menuId)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE Weibo_Menu WHERE MenuId = @MenuId");
     this.database.AddInParameter(sqlStringCommand, "MenuId", System.Data.DbType.Int32, menuId);
     return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Exemplo n.º 49
0
 public int CreateCategory(CategoryInfo category)
 {
     System.Data.Common.DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_Category_Create");
     this.database.AddOutParameter(storedProcCommand, "CategoryId", System.Data.DbType.Int32, 4);
     this.database.AddInParameter(storedProcCommand, "Name", System.Data.DbType.String, category.Name);
     this.database.AddInParameter(storedProcCommand, "SKUPrefix", System.Data.DbType.String, category.SKUPrefix);
     this.database.AddInParameter(storedProcCommand, "DisplaySequence", System.Data.DbType.Int32, category.DisplaySequence);
     if (!string.IsNullOrEmpty(category.IconUrl))
     {
         this.database.AddInParameter(storedProcCommand, "IconUrl", System.Data.DbType.String, category.IconUrl);
     }
     if (!string.IsNullOrEmpty(category.MetaTitle))
     {
         this.database.AddInParameter(storedProcCommand, "Meta_Title", System.Data.DbType.String, category.MetaTitle);
     }
     if (!string.IsNullOrEmpty(category.MetaDescription))
     {
         this.database.AddInParameter(storedProcCommand, "Meta_Description", System.Data.DbType.String, category.MetaDescription);
     }
     if (!string.IsNullOrEmpty(category.MetaKeywords))
     {
         this.database.AddInParameter(storedProcCommand, "Meta_Keywords", System.Data.DbType.String, category.MetaKeywords);
     }
     if (!string.IsNullOrEmpty(category.Notes1))
     {
         this.database.AddInParameter(storedProcCommand, "Notes1", System.Data.DbType.String, category.Notes1);
     }
     if (!string.IsNullOrEmpty(category.Notes2))
     {
         this.database.AddInParameter(storedProcCommand, "Notes2", System.Data.DbType.String, category.Notes2);
     }
     if (!string.IsNullOrEmpty(category.Notes3))
     {
         this.database.AddInParameter(storedProcCommand, "Notes3", System.Data.DbType.String, category.Notes3);
     }
     if (!string.IsNullOrEmpty(category.Notes4))
     {
         this.database.AddInParameter(storedProcCommand, "Notes4", System.Data.DbType.String, category.Notes4);
     }
     if (!string.IsNullOrEmpty(category.Notes5))
     {
         this.database.AddInParameter(storedProcCommand, "Notes5", System.Data.DbType.String, category.Notes5);
     }
     if (category.ParentCategoryId.HasValue)
     {
         this.database.AddInParameter(storedProcCommand, "ParentCategoryId", System.Data.DbType.Int32, category.ParentCategoryId.Value);
     }
     else
     {
         this.database.AddInParameter(storedProcCommand, "ParentCategoryId", System.Data.DbType.Int32, 0);
     }
     if (category.AssociatedProductType.HasValue)
     {
         this.database.AddInParameter(storedProcCommand, "AssociatedProductType", System.Data.DbType.Int32, category.AssociatedProductType.Value);
     }
     if (!string.IsNullOrEmpty(category.RewriteName))
     {
         this.database.AddInParameter(storedProcCommand, "RewriteName", System.Data.DbType.String, category.RewriteName);
     }
     this.database.AddInParameter(storedProcCommand, "FirstCommission", System.Data.DbType.String, category.FirstCommission);
     this.database.AddInParameter(storedProcCommand, "SecondCommission", System.Data.DbType.String, category.SecondCommission);
     this.database.AddInParameter(storedProcCommand, "ThirdCommission", System.Data.DbType.String, category.ThirdCommission);
     this.database.ExecuteNonQuery(storedProcCommand);
     return((int)this.database.GetParameterValue(storedProcCommand, "CategoryId"));
 }
 internal GridReader(IDbCommand command, IDataReader reader, Identity identity, DynamicParameters dynamicParams, bool addToCache, CancellationToken cancel)
     : this(command, reader, identity, dynamicParams, addToCache)
 {
     this.cancel = cancel;
 }
Exemplo n.º 51
0
 public bool SetGradeDefault(int gradeid)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_DistributorGrade set IsDefault=0 where GradeId<>@GradeId;UPDATE aspnet_DistributorGrade set IsDefault=1 where GradeId=@GradeId");
     this.database.AddInParameter(sqlStringCommand, "GradeId", System.Data.DbType.Int32, gradeid);
     return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Exemplo n.º 52
0
 public void ReaderExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext <System.Data.Common.DbDataReader> interceptionContext)
 {
     LogSQLInfo(command, interceptionContext, "ReaderExecuting");
 }
Exemplo n.º 53
0
 public void NonQueryExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext <int> interceptionContext)
 {
     //LogSQLInfo(command, interceptionContext, "NonQueryExecuting");
 }
Exemplo n.º 54
0
        public bool CreateShippingTemplate(FreightTemplate freightTemplate)
        {
            this.Error = "";
            bool flag = false;

            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("select name from Hishop_FreightTemplate_Templates where name=@Name");
            this.database.AddInParameter(sqlStringCommand, "Name", System.Data.DbType.String, freightTemplate.Name);
            System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand);
            bool result;

            if (!dataReader.Read())
            {
                System.Data.Common.DbCommand sqlStringCommand2 = this.database.GetSqlStringCommand("INSERT INTO Hishop_FreightTemplate_Templates(Name,FreeShip,MUnit,HasFree)VALUES(@Name,@FreeShip,@MUnit,@HasFree)");
                this.database.AddInParameter(sqlStringCommand2, "Name", System.Data.DbType.String, freightTemplate.Name);
                this.database.AddInParameter(sqlStringCommand2, "FreeShip", System.Data.DbType.Int16, freightTemplate.FreeShip);
                this.database.AddInParameter(sqlStringCommand2, "MUnit", System.Data.DbType.Int16, freightTemplate.MUnit);
                this.database.AddInParameter(sqlStringCommand2, "HasFree", System.Data.DbType.Int16, freightTemplate.HasFree);
                using (System.Data.Common.DbConnection dbConnection = this.database.CreateConnection())
                {
                    dbConnection.Open();
                    System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction();
                    try
                    {
                        this.database.ExecuteNonQuery(sqlStringCommand2, dbTransaction);
                        sqlStringCommand2 = this.database.GetSqlStringCommand("SELECT @@Identity");
                        object obj = this.database.ExecuteScalar(sqlStringCommand2, dbTransaction);
                        int    num = 0;
                        if (obj != null && obj != DBNull.Value)
                        {
                            int.TryParse(obj.ToString(), out num);
                            this.Error = num.ToString();
                            flag       = (num > 0);
                        }
                        if (flag && !freightTemplate.FreeShip)
                        {
                            System.Data.Common.DbCommand sqlStringCommand3 = this.database.GetSqlStringCommand(" ");
                            this.database.AddInParameter(sqlStringCommand3, "TemplateId", System.Data.DbType.Int32, num);
                            if (freightTemplate.FreeShippings != null && freightTemplate.FreeShippings.Count > 0)
                            {
                                StringBuilder stringBuilder = new StringBuilder();
                                int           num2          = 0;
                                int           num3          = 0;
                                stringBuilder.Append("DECLARE @ERR INT; Set @ERR =0;");
                                stringBuilder.Append(" DECLARE @FreeId Int;");
                                foreach (FreeShipping current in freightTemplate.FreeShippings)
                                {
                                    stringBuilder.Append(" INSERT INTO Hishop_FreightTemplate_FreeShipping(TemplateId,ModeId,ConditionNumber,ConditionType) VALUES( @TemplateId,").Append("@ModeId").Append(num2).Append(",@ConditionNumber").Append(num2).Append(",@ConditionType").Append(num2).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                    this.database.AddInParameter(sqlStringCommand3, "ModeId" + num2, System.Data.DbType.Int32, current.ModeId);
                                    this.database.AddInParameter(sqlStringCommand3, "ConditionNumber" + num2, System.Data.DbType.String, current.ConditionNumber);
                                    this.database.AddInParameter(sqlStringCommand3, "ConditionType" + num2, System.Data.DbType.Int32, current.ConditionType);
                                    stringBuilder.Append("Set @FreeId =@@identity;");
                                    if (current.FreeShippingRegions != null)
                                    {
                                        foreach (FreeShippingRegion current2 in current.FreeShippingRegions)
                                        {
                                            stringBuilder.Append(" INSERT INTO Hishop_FreightTemplate_FreeShippingRegions(FreeId,TemplateId,RegionId) VALUES(@FreeId,@TemplateId,").Append("@RegionId").Append(num3).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                            this.database.AddInParameter(sqlStringCommand3, "RegionId" + num3, System.Data.DbType.Int32, current2.RegionId);
                                            num3++;
                                        }
                                    }
                                    num2++;
                                }
                                sqlStringCommand3.CommandText = stringBuilder.Append("SELECT @ERR;").ToString();
                                int num4 = (int)this.database.ExecuteScalar(sqlStringCommand3, dbTransaction);
                                if (num4 != 0)
                                {
                                    this.Error = "指定包邮信息部份有错误,请查检!";
                                    dbTransaction.Rollback();
                                    flag = false;
                                }
                            }
                            if (flag && freightTemplate.SpecifyRegionGroups != null && freightTemplate.SpecifyRegionGroups.Count > 0)
                            {
                                sqlStringCommand3 = this.database.GetSqlStringCommand(" ");
                                this.database.AddInParameter(sqlStringCommand3, "TemplateId", System.Data.DbType.Int32, num);
                                StringBuilder stringBuilder = new StringBuilder();
                                int           num2          = 0;
                                int           num3          = 0;
                                stringBuilder.Append("DECLARE @ERR INT; Set @ERR =0;");
                                stringBuilder.Append(" DECLARE @GroupId Int;");
                                foreach (SpecifyRegionGroup current3 in freightTemplate.SpecifyRegionGroups)
                                {
                                    stringBuilder.Append(" INSERT INTO Hishop_FreightTemplate_SpecifyRegionGroups(TemplateId,ModeId,FristNumber,FristPrice,AddNumber,AddPrice,IsDefault) VALUES(@TemplateId,").Append("@ModeId").Append(num2).Append(",@FristNumber").Append(num2).Append(",@FristPrice").Append(num2).Append(",@AddNumber").Append(num2).Append(",@AddPrice").Append(num2).Append(",@IsDefault").Append(num2).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                    this.database.AddInParameter(sqlStringCommand3, "ModeId" + num2, System.Data.DbType.Int16, current3.ModeId);
                                    this.database.AddInParameter(sqlStringCommand3, "FristNumber" + num2, System.Data.DbType.Decimal, current3.FristNumber);
                                    this.database.AddInParameter(sqlStringCommand3, "FristPrice" + num2, System.Data.DbType.Currency, current3.FristPrice);
                                    this.database.AddInParameter(sqlStringCommand3, "AddPrice" + num2, System.Data.DbType.Currency, current3.AddPrice);
                                    this.database.AddInParameter(sqlStringCommand3, "AddNumber" + num2, System.Data.DbType.Decimal, current3.AddNumber);
                                    this.database.AddInParameter(sqlStringCommand3, "IsDefault" + num2, System.Data.DbType.Int16, current3.IsDefault);
                                    stringBuilder.Append("Set @GroupId =@@identity;");
                                    if (current3.SpecifyRegions != null)
                                    {
                                        foreach (SpecifyRegion current4 in current3.SpecifyRegions)
                                        {
                                            stringBuilder.Append(" INSERT INTO Hishop_FreightTemplate_SpecifyRegions(TemplateId,GroupId,RegionId) VALUES(@TemplateId,@GroupId").Append(",@RegionId").Append(num3).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                            this.database.AddInParameter(sqlStringCommand3, "RegionId" + num3, System.Data.DbType.Int32, current4.RegionId);
                                            num3++;
                                        }
                                    }
                                    num2++;
                                }
                                sqlStringCommand3.CommandText = stringBuilder.Append("SELECT @ERR;").ToString();
                                int num4 = (int)this.database.ExecuteScalar(sqlStringCommand3, dbTransaction);
                                if (num4 != 0)
                                {
                                    this.Error = "运送方式部份信息有错误,请查检!";
                                    dbTransaction.Rollback();
                                    flag = false;
                                }
                            }
                        }
                        dbTransaction.Commit();
                    }
                    catch
                    {
                        if (dbTransaction.Connection != null)
                        {
                            dbTransaction.Rollback();
                        }
                        flag = false;
                    }
                    finally
                    {
                        dbConnection.Close();
                    }
                }
                result = flag;
            }
            else
            {
                dataReader.Close();
                result = false;
            }
            return(result);
        }
Exemplo n.º 55
0
 public void ScalarExecuting(System.Data.Common.DbCommand command, DbCommandInterceptionContext <object> interceptionContext)
 {
     LogSQLInfo(command, interceptionContext, "ScalarExecuting");
 }
Exemplo n.º 56
0
        public bool UpdateShippingTemplate(FreightTemplate freightTemplate, string templateName)
        {
            bool result;

            if (freightTemplate.TemplateId == 0)
            {
                this.Error = "模板ID不存在!";
                result     = false;
            }
            else
            {
                bool flag = false;
                System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("select name from Hishop_FreightTemplate_Templates where name=@Name and name<>@ReName");
                this.database.AddInParameter(sqlStringCommand, "Name", System.Data.DbType.String, freightTemplate.Name);
                this.database.AddInParameter(sqlStringCommand, "ReName", System.Data.DbType.String, templateName);
                System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand);
                if (!dataReader.Read())
                {
                    StringBuilder stringBuilder = new StringBuilder("UPDATE Hishop_FreightTemplate_Templates SET Name=@Name,FreeShip=@FreeShip,MUnit=@MUnit,HasFree=@HasFree WHERE TemplateId=@TemplateId;");
                    System.Data.Common.DbCommand sqlStringCommand2 = this.database.GetSqlStringCommand(stringBuilder.ToString());
                    this.database.AddInParameter(sqlStringCommand2, "Name", System.Data.DbType.String, freightTemplate.Name);
                    this.database.AddInParameter(sqlStringCommand2, "FreeShip", System.Data.DbType.Int16, freightTemplate.FreeShip);
                    this.database.AddInParameter(sqlStringCommand2, "MUnit", System.Data.DbType.Int16, freightTemplate.MUnit);
                    this.database.AddInParameter(sqlStringCommand2, "TemplateId", System.Data.DbType.Int32, freightTemplate.TemplateId);
                    this.database.AddInParameter(sqlStringCommand2, "HasFree", System.Data.DbType.Int16, freightTemplate.HasFree);
                    using (System.Data.Common.DbConnection dbConnection = this.database.CreateConnection())
                    {
                        dbConnection.Open();
                        System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction();
                        try
                        {
                            flag = (this.database.ExecuteNonQuery(sqlStringCommand2, dbTransaction) > 0);
                            System.Data.Common.DbCommand sqlStringCommand3 = this.database.GetSqlStringCommand(" ");
                            StringBuilder stringBuilder2 = new StringBuilder();
                            if (flag)
                            {
                                this.database.AddInParameter(sqlStringCommand3, "TemplateId", System.Data.DbType.Int32, freightTemplate.TemplateId);
                                stringBuilder2.Append("delete from Hishop_FreightTemplate_SpecifyRegionGroups WHERE TemplateId=@TemplateId;");
                                stringBuilder2.Append("delete from Hishop_FreightTemplate_FreeShipping WHERE TemplateId=@TemplateId;");
                                stringBuilder2.Append("delete from Hishop_FreightTemplate_FreeShippingRegions WHERE TemplateId=@TemplateId;");
                                stringBuilder2.Append("delete from Hishop_FreightTemplate_SpecifyRegions WHERE TemplateId=@TemplateId;");
                                sqlStringCommand3.CommandText = stringBuilder2.ToString();
                                this.database.ExecuteNonQuery(sqlStringCommand3, dbTransaction);
                            }
                            if (flag && !freightTemplate.FreeShip)
                            {
                                if (freightTemplate.FreeShippings != null && freightTemplate.FreeShippings.Count > 0)
                                {
                                    sqlStringCommand3 = this.database.GetSqlStringCommand(" ");
                                    this.database.AddInParameter(sqlStringCommand3, "TemplateId", System.Data.DbType.Int32, freightTemplate.TemplateId);
                                    stringBuilder2.Clear();
                                    int num  = 0;
                                    int num2 = 0;
                                    stringBuilder2.Append("DECLARE @ERR INT; Set @ERR =0;");
                                    stringBuilder2.Append(" DECLARE @FreeId Int;");
                                    foreach (FreeShipping current in freightTemplate.FreeShippings)
                                    {
                                        stringBuilder2.Append(" INSERT INTO Hishop_FreightTemplate_FreeShipping(TemplateId,ModeId,ConditionNumber,ConditionType) VALUES( @TemplateId,").Append("@ModeId").Append(num).Append(",@ConditionNumber").Append(num).Append(",@ConditionType").Append(num).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                        this.database.AddInParameter(sqlStringCommand3, "ModeId" + num, System.Data.DbType.Int32, current.ModeId);
                                        this.database.AddInParameter(sqlStringCommand3, "ConditionNumber" + num, System.Data.DbType.String, current.ConditionNumber);
                                        this.database.AddInParameter(sqlStringCommand3, "ConditionType" + num, System.Data.DbType.Int32, current.ConditionType);
                                        stringBuilder2.Append("Set @FreeId =@@identity;");
                                        if (current.FreeShippingRegions != null)
                                        {
                                            foreach (FreeShippingRegion current2 in current.FreeShippingRegions)
                                            {
                                                stringBuilder2.Append(" INSERT INTO Hishop_FreightTemplate_FreeShippingRegions(FreeId,TemplateId,RegionId) VALUES(@FreeId,@TemplateId").Append(",@RegionId").Append(num2).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                                this.database.AddInParameter(sqlStringCommand3, "RegionId" + num2, System.Data.DbType.Int32, current2.RegionId);
                                                num2++;
                                            }
                                        }
                                        num++;
                                    }
                                    sqlStringCommand3.CommandText = stringBuilder2.Append("SELECT @ERR;").ToString();
                                    int num3 = (int)this.database.ExecuteScalar(sqlStringCommand3, dbTransaction);
                                    if (num3 != 0)
                                    {
                                        dbTransaction.Rollback();
                                        flag = false;
                                    }
                                }
                                if (flag && freightTemplate.SpecifyRegionGroups != null && freightTemplate.SpecifyRegionGroups.Count > 0)
                                {
                                    sqlStringCommand3 = this.database.GetSqlStringCommand(" ");
                                    this.database.AddInParameter(sqlStringCommand3, "TemplateId", System.Data.DbType.Int32, freightTemplate.TemplateId);
                                    stringBuilder2.Clear();
                                    int num  = 0;
                                    int num2 = 0;
                                    stringBuilder2.Append("DECLARE @ERR INT; Set @ERR =0;");
                                    stringBuilder2.Append(" DECLARE @GroupId Int;");
                                    foreach (SpecifyRegionGroup current3 in freightTemplate.SpecifyRegionGroups)
                                    {
                                        stringBuilder2.Append(" INSERT INTO Hishop_FreightTemplate_SpecifyRegionGroups(TemplateId,ModeId,FristNumber,FristPrice,AddNumber,AddPrice,IsDefault) VALUES(@TemplateId,").Append("@ModeId").Append(num).Append(",@FristNumber").Append(num).Append(",@FristPrice").Append(num).Append(",@AddNumber").Append(num).Append(",@AddPrice").Append(num).Append(",@IsDefault").Append(num).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                        this.database.AddInParameter(sqlStringCommand3, "ModeId" + num, System.Data.DbType.Int16, current3.ModeId);
                                        this.database.AddInParameter(sqlStringCommand3, "FristNumber" + num, System.Data.DbType.Decimal, current3.FristNumber);
                                        this.database.AddInParameter(sqlStringCommand3, "FristPrice" + num, System.Data.DbType.Currency, current3.FristPrice);
                                        this.database.AddInParameter(sqlStringCommand3, "AddPrice" + num, System.Data.DbType.Currency, current3.AddPrice);
                                        this.database.AddInParameter(sqlStringCommand3, "AddNumber" + num, System.Data.DbType.Decimal, current3.AddNumber);
                                        this.database.AddInParameter(sqlStringCommand3, "IsDefault" + num, System.Data.DbType.Int16, current3.IsDefault);
                                        stringBuilder2.Append("Set @GroupId =@@identity;");
                                        if (current3.SpecifyRegions != null)
                                        {
                                            foreach (SpecifyRegion current4 in current3.SpecifyRegions)
                                            {
                                                stringBuilder2.Append(" INSERT INTO Hishop_FreightTemplate_SpecifyRegions(TemplateId,GroupId,RegionId) VALUES(@TemplateId,@GroupId").Append(",@RegionId").Append(num2).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                                this.database.AddInParameter(sqlStringCommand3, "RegionId" + num2, System.Data.DbType.Int32, current4.RegionId);
                                                num2++;
                                            }
                                        }
                                        num++;
                                    }
                                    sqlStringCommand3.CommandText = stringBuilder2.Append("SELECT @ERR;").ToString();
                                    int num3 = (int)this.database.ExecuteScalar(sqlStringCommand3, dbTransaction);
                                    if (num3 != 0)
                                    {
                                        dbTransaction.Rollback();
                                        flag = false;
                                    }
                                }
                            }
                            if (flag)
                            {
                                dbTransaction.Commit();
                            }
                            else
                            {
                                dbTransaction.Rollback();
                            }
                        }
                        catch
                        {
                            if (dbTransaction.Connection != null)
                            {
                                dbTransaction.Rollback();
                            }
                            flag = false;
                        }
                        finally
                        {
                            dbConnection.Close();
                        }
                    }
                    result = flag;
                }
                else
                {
                    dataReader.Close();
                    result = false;
                }
            }
            return(result);
        }
Exemplo n.º 57
0
        public FreightTemplate GetFreightTemplate(int templateId, bool includeDetail)
        {
            FreightTemplate freightTemplate = new FreightTemplate();

            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand(" SELECT * FROM Hishop_FreightTemplate_Templates Where TemplateId =@TemplateId");
            if (includeDetail)
            {
                System.Data.Common.DbCommand expr_24 = sqlStringCommand;
                expr_24.CommandText += " SELECT * FROM Hishop_FreightTemplate_FreeShipping g,vw_Hishop_FreightTemplate_FreeShippingRegions r Where g.FreeId=r.FreeId and TemplateId =@TemplateId";
                System.Data.Common.DbCommand expr_3B = sqlStringCommand;
                expr_3B.CommandText += " SELECT g.*,r.RegionIds FROM Hishop_FreightTemplate_SpecifyRegionGroups g  LEFT JOIN  vw_Hishop_FreightTemplate_SpecifyRegions r on (g.GroupId=r.GroupId) where  g.TemplateId =@TemplateId";
            }
            this.database.AddInParameter(sqlStringCommand, "TemplateId", System.Data.DbType.Int32, templateId);
            using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    if (dataReader["TemplateId"] != DBNull.Value)
                    {
                        freightTemplate.TemplateId = (int)dataReader["TemplateId"];
                    }
                    freightTemplate.Name     = (string)dataReader["Name"];
                    freightTemplate.FreeShip = (bool)dataReader["FreeShip"];
                    freightTemplate.HasFree  = (bool)dataReader["HasFree"];
                    freightTemplate.MUnit    = (int)((byte)dataReader["MUnit"]);
                }
                if (includeDetail)
                {
                    dataReader.NextResult();
                    freightTemplate.FreeShippings = new List <FreeShipping>();
                    while (dataReader.Read())
                    {
                        FreeShipping freeShipping = new FreeShipping();
                        freeShipping.TemplateId      = (int)dataReader["TemplateId"];
                        freeShipping.ModeId          = (int)((byte)dataReader["ModeId"]);
                        freeShipping.FreeId          = (int)((decimal)dataReader["FreeId"]);
                        freeShipping.ConditionNumber = (string)dataReader["ConditionNumber"];
                        freeShipping.ConditionType   = (int)((byte)dataReader["ConditionType"]);
                        freeShipping.RegionIds       = (string)dataReader["RegionIds"];
                        freightTemplate.FreeShippings.Add(freeShipping);
                    }
                    dataReader.NextResult();
                    freightTemplate.SpecifyRegionGroups = new List <SpecifyRegionGroup>();
                    while (dataReader.Read())
                    {
                        SpecifyRegionGroup specifyRegionGroup = new SpecifyRegionGroup();
                        specifyRegionGroup.TemplateId  = (int)dataReader["TemplateId"];
                        specifyRegionGroup.GroupId     = (int)dataReader["GroupId"];
                        specifyRegionGroup.FristNumber = (decimal)dataReader["FristNumber"];
                        specifyRegionGroup.FristPrice  = (decimal)dataReader["FristPrice"];
                        specifyRegionGroup.AddNumber   = (decimal)dataReader["AddNumber"];
                        specifyRegionGroup.AddPrice    = (decimal)dataReader["AddPrice"];
                        specifyRegionGroup.ModeId      = (int)((byte)dataReader["ModeId"]);
                        specifyRegionGroup.IsDefault   = (bool)dataReader["IsDefault"];
                        string regionIds = "";
                        if (DBNull.Value != dataReader["RegionIds"])
                        {
                            regionIds = (string)dataReader["RegionIds"];
                        }
                        specifyRegionGroup.RegionIds = regionIds;
                        freightTemplate.SpecifyRegionGroups.Add(specifyRegionGroup);
                    }
                }
            }
            return(freightTemplate);
        }
Exemplo n.º 58
0
 public bool DeleteShippingTemplate(int templateId)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE FROM Hishop_FreightTemplate_Templates Where TemplateId=@TemplateId");
     this.database.AddInParameter(sqlStringCommand, "TemplateId", System.Data.DbType.Int32, templateId);
     return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Exemplo n.º 59
0
 public override bool DeleteMemberGrade(int gradeId)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE FROM aspnet_MemberGrades WHERE GradeId = @GradeId AND IsDefault = 0 AND NOT EXISTS(SELECT * FROM aspnet_Members WHERE GradeId = @GradeId)");
     this.database.AddInParameter(sqlStringCommand, "GradeId", System.Data.DbType.Int32, gradeId);
     return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Exemplo n.º 60
-1
        private static void PrepareCommand(
            DbCommand command,
            DbConnection connection,
            DbTransaction transaction,
            CommandType commandType,
            string commandText,
            DbParameter[] commandParameters)
        {
            if (command == null) throw new ArgumentNullException("command");
            if (commandText == null || commandText.Length == 0) throw new ArgumentNullException("commandText");

            command.Connection = connection;
            command.CommandText = commandText;
            command.CommandType = commandType;

            if (transaction != null)
            {
                if (transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
                command.Transaction = transaction;
            }

            if (commandParameters != null)
            {
                AttachParameters(command, commandParameters);
            }
            return;
        }