PrepareCommand() private static method

This method opens (if necessary) and assigns a connection, transaction, command type and parameters to the provided command.
private static PrepareCommand ( SqlCommand command, SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter commandParameters ) : void
command SqlCommand the SqlCommand to be prepared
connection SqlConnection a valid SqlConnection, on which to execute this command
transaction SqlTransaction a valid SqlTransaction, or 'null'
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
commandParameters SqlParameter an array of SqlParameters to be associated with the command or 'null' if no parameters are required
return void
コード例 #1
0
        /// <summary>
        /// audit
        /// <summary>
        /// <param name=formid>formid</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Audit(string formid, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                sql = string.Format("update asset_add set status={0},update_user='******',update_time=getdate() where form_id='{2}'", 1, updateuser, formid);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
コード例 #2
0
ファイル: SQLLink.cs プロジェクト: xzc5858/WinAtt
 public void FillDataTable(DataTable dt, string commandText, int iStart, int iMax)
 {
     if ((this._connString == null) || (this._connString.Length == 0))
     {
         throw new ArgumentNullException("connectionString");
     }
     using (SqlConnection connection = new SqlConnection(this._connString))
     {
         connection.Open();
         if (connection == null)
         {
             throw new ArgumentNullException("connection");
         }
         SqlCommand command             = new SqlCommand();
         bool       mustCloseConnection = false;
         SqlHelper.PrepareCommand(command, connection, null, CommandType.Text, commandText, null, out mustCloseConnection);
         using (SqlDataAdapter adapter = new SqlDataAdapter(command))
         {
             DataSet dataSet = new DataSet();
             dataSet.Tables.Add(dt);
             adapter.Fill(dataSet, iStart, iMax, dt.TableName);
             command.Parameters.Clear();
             if (mustCloseConnection)
             {
                 connection.Close();
             }
         }
     }
 }
コード例 #3
0
        public void FillDataset(string commandText, DataSet dataSet, string[] tableNames)
        {
            //objDataSet=SqlHelper.ExecuteDataset(ConnectionString,this.CommandType,commandText,CommandParameters);
            //return objDataSet;
            SqlCommand     command             = new SqlCommand();
            bool           mustCloseConnection = false;
            SqlTransaction objTransaction      = GetTransactionObject(DEFAULT_TRANSACTION_NAME);

            //SqlHelper.FillDataset(connection,commandText,dataSet,tableNames,commandParameters);
            SqlHelper.PrepareCommand(command, this.WrapperSqlConnection, objTransaction, this.CommandType, commandText, CommandParameters, out mustCloseConnection);
            sqlDataAdapter = new SqlDataAdapter(command);
            // Add the table mappings specified by the user
            if (tableNames != null && tableNames.Length > 0)
            {
                string tableName = "Table";
                for (int index = 0; index < tableNames.Length; index++)
                {
                    if (tableNames[index] == null || tableNames[index].Length == 0)
                    {
                        throw new ArgumentException("The tableNames parameter must contain a list of tables, a value was provided as null or empty string.", "tableNames");
                    }
                    sqlDataAdapter.TableMappings.Add(tableName, tableNames[index]);
                    tableName += (index + 1).ToString();
                }
            }

            sqlDataAdapter.Fill(dataSet);
            //SqlHelper.FillDataset(ConnectionString,commandType,commandText,dataSet,tableNames,CommandParameters);
        }
コード例 #4
0
        public override int Query(MapperCommand command)
        {
            int num;

            SqlParameter[] dbParameter = command.Parameter.ToDbParameter <SqlParameter>();
            using (SqlConnection sqlConnection = new SqlConnection(this.connectionString))
            {
                sqlConnection.Open();
                SqlCommand sqlCommand = new SqlCommand();
                bool       flag       = false;
                SqlHelper.PrepareCommand(sqlCommand, sqlConnection, null, (System.Data.CommandType)command.Type, command.Text, dbParameter, out flag);
                if (command.Timeout > SqlHelper.CommandTimeout)
                {
                    sqlCommand.CommandTimeout = command.Timeout;
                }
                int num1 = sqlCommand.ExecuteNonQuery();
                sqlCommand.Parameters.Clear();
                if (flag)
                {
                    sqlConnection.Close();
                }
                if (command.Type != Test.Core.CommandType.Text)
                {
                    this.UpdateParameter(command.Parameter, dbParameter);
                }
                num = num1;
            }
            return(num);
        }
コード例 #5
0
ファイル: SQLLink.cs プロジェクト: xzc5858/WinAtt
        /// <summary>
        /// 通过存储过程来绑定数据
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="prname"></param>
        /// <param name="parameter"></param>
        public void FillDataTable(DataTable dt, string prname, SqlParameter[] parameter)
        {
            if ((this._connString == null) || (this._connString.Length == 0))
            {
                throw new ArgumentNullException("connectionString");
            }

            using (SqlConnection connection = new SqlConnection(this._connString))
            {
                connection.Open();
                if (connection == null)
                {
                    throw new ArgumentNullException("connection");
                }
                SqlCommand command             = new SqlCommand();
                bool       mustCloseConnection = false;

                SqlHelper.PrepareCommand(command, connection, null, CommandType.StoredProcedure, prname, parameter, out mustCloseConnection);

                using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                {
                    dt.Clear();
                    adapter.Fill(dt);
                    command.Parameters.Clear();
                    if (mustCloseConnection)
                    {
                        connection.Close();
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// audit production form
        /// <summary>
        /// <param name=formid>formid</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Audit(string formid, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                modProductionForm mod = GetItem(formid, out emsg);
                if (mod.Status == 1)
                {
                    emsg = "这张单据已经审核,您无须再审";
                    return(false);
                }
                BindingCollection <modProductionFormWare> listware = GetProductionFormWare(formid, out emsg);
                if (listware != null && listware.Count > 0)
                {
                    foreach (modProductionFormWare modware in listware)
                    {
                        sql = string.Format("insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate())", modware.WarehouseId, modware.ProductId, modware.Size, formid, mod.FormType, mod.No, mod.FormDate, 0, modware.Qty, 0, modware.Remark, updateuser);
                        SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                        cmd.ExecuteNonQuery();
                    }
                }
                BindingCollection <modProductionFormMaterial> listmaterial = GetProductionFormMaterial(formid, out emsg);
                if (listmaterial != null && listmaterial.Count > 0)
                {
                    foreach (modProductionFormMaterial modmaterial in listmaterial)
                    {
                        sql = string.Format("insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate())", modmaterial.WarehouseId, modmaterial.ProductId, modmaterial.Size, formid, mod.FormType, mod.No, mod.FormDate, 0, 0, modmaterial.Qty, modmaterial.Remark, updateuser);
                        SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                        cmd.ExecuteNonQuery();
                    }
                }
                sql = string.Format("update production_form set status={0},audit_man='{1}',audit_time=getdate() where form_id='{2}'", 1, updateuser, formid);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
コード例 #7
0
ファイル: FormMainDao.cs プロジェクト: icprog/HengDa
        void AddTwo(SqlCommand cmd, HengDaEntity.FormMainTwo _modelTwo, StringBuilder strSql, SqlTransaction tran, SqlConnection conn)
        {
            strSql = new StringBuilder( );
            strSql.Append("INSERT INTO  HDSHF (");
            strSql.Append("SHF001,SHF002,SHF003,SHF004,SHF005,SHF006,SHF007,SHF008)");
            strSql.Append(" VALUES (");
            strSql.Append("@SHF001,@SHF002,@SHF003,@SHF004,@SHF005,@SHF006,@SHF007,@SHF008)");
            SqlParameter[] parameter =
            {
                new SqlParameter("@SHF001", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHF002", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHF003", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHF004", SqlDbType.Int),
                new SqlParameter("@SHF005", SqlDbType.Decimal,   6),
                new SqlParameter("@SHF006", SqlDbType.Int),
                new SqlParameter("@SHF007", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHF008", SqlDbType.NVarChar, 255)
            };
            parameter[0].Value = _modelTwo.SHF001;
            parameter[1].Value = _modelTwo.SHF002;
            parameter[2].Value = _modelTwo.SHF003;
            parameter[3].Value = _modelTwo.SHF004;
            parameter[4].Value = _modelTwo.SHF005;
            parameter[5].Value = _modelTwo.SHF006;
            parameter[6].Value = _modelTwo.SHF007;
            parameter[7].Value = _modelTwo.SHF008;

            cmd.Parameters.Clear( );
            SqlHelper.PrepareCommand(cmd, conn, tran, strSql.ToString( ), parameter);
            cmd.CommandText = strSql.ToString( );
            cmd.ExecuteNonQuery( );
        }
コード例 #8
0
        /// <summary>
        /// reset production form
        /// <summary>
        /// <param name=formid>formid</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool ResetPrice(string formid, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                modProductionForm mod = GetItem(formid, out emsg);
                sql = string.Format("update production_form set price_status={0} where form_id='{2}'", 0, updateuser, formid);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
コード例 #9
0
    public static SqlDataReader ExecuteReader(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
    {
        SqlConnection sqlConnection = new SqlConnection(connectionString);
        SqlDataReader result;

        try
        {
            using (SqlCommand sqlCommand = new SqlCommand())
            {
                if (sqlConnection.State != ConnectionState.Open)
                {
                    sqlConnection.Open();
                }
                else
                {
                    sqlConnection.Close();
                    sqlConnection.Open();
                }
                SqlHelper.PrepareCommand(sqlCommand, sqlConnection, null, cmdType, cmdText, commandParameters);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
                sqlCommand.Parameters.Clear();
                result = sqlDataReader;
            }
        }
        catch (Exception ex)
        {
            sqlConnection.Close();
            throw;
        }
        return(result);
    }
コード例 #10
0
ファイル: DALACCEXPENSEFORM.cs プロジェクト: 100009/hberp
        /// <summary>
        /// reset
        /// <summary>
        /// <param name=id>id</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Reset(int id, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                sql = string.Format("update acc_expense_form set status={0},audit_man='{1}',audit_time=null where id={2}", 0, updateuser, id);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Prepares the command.
        /// </summary>
        /// <param name="commandType">Type of the command.</param>
        /// <param name="commandText">The command text.</param>
        /// <returns>Command object.</returns>
        public override IDbCommand PrepareCommand(CommandType commandType, string commandText)
        {
            this.Open();
            SqlCommand command             = new SqlCommand();
            bool       mustCloseConnection = false;

            SqlHelper.PrepareCommand(command, this.SqlConnection, null, commandType, commandText, null, out mustCloseConnection);
            return(command);
        }
コード例 #12
0
        /// <summary>
        /// Prepares the command.
        /// </summary>
        /// <param name="spName">Name of the sp.</param>
        /// <param name="parameterValues">The parameter values.</param>
        /// <returns>Command object.</returns>
        public override IDbCommand PrepareCommand(string spName, params DbParameter[] parameterValues)
        {
            this.Open();
            SqlCommand command             = new SqlCommand();
            bool       mustCloseConnection = false;

            SqlHelper.PrepareCommand(command, this.SqlConnection, null, CommandType.StoredProcedure, spName, (SqlParameter[])parameterValues, out mustCloseConnection);
            return(command);
        }
コード例 #13
0
    public static object ExecuteScalar(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
    {
        SqlCommand sqlCommand = new SqlCommand();

        SqlHelper.PrepareCommand(sqlCommand, connection, null, cmdType, cmdText, commandParameters);
        object result = sqlCommand.ExecuteScalar();

        sqlCommand.Parameters.Clear();
        return(result);
    }
コード例 #14
0
    public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
    {
        SqlCommand sqlCommand = new SqlCommand();

        SqlHelper.PrepareCommand(sqlCommand, trans.Connection, trans, cmdType, cmdText, commandParameters);
        int result = sqlCommand.ExecuteNonQuery();

        sqlCommand.Parameters.Clear();
        return(result);
    }
コード例 #15
0
        /// <summary>
        /// audit warehouse inout
        /// <summary>
        /// <param name=id>id</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Audit(int id, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                modWarehouseInoutForm mod = GetItem(id, out emsg);
                if (mod.Status == 1)
                {
                    emsg = "这张单据已经审核,您无须再审";
                    return(false);
                }
                if (mod.InoutFlag == 1)
                {
                    sql = string.Format("insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate())", mod.WarehouseId, mod.ProductId, mod.Size, id, mod.InoutType, mod.No, mod.InoutDate, 0, mod.Qty, 0, mod.Remark, updateuser);
                }
                else
                {
                    sql = string.Format("insert into warehouse_product_inout(warehouse_id,product_id,size,form_id,form_type,inv_no,inout_date,start_qty,input_qty,output_qty,remark,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate())", mod.WarehouseId, mod.ProductId, mod.Size, id, mod.InoutType, mod.No, mod.InoutDate, 0, 0, mod.Qty, mod.Remark, updateuser);
                }
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                sql = string.Format("update warehouse_inout_form set status={0},audit_man='{1}',audit_time=getdate() where id='{2}'", 1, updateuser, id);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
コード例 #16
0
    public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
    {
        SqlCommand sqlCommand = new SqlCommand();
        int        result;

        using (SqlConnection sqlConnection = new SqlConnection(connectionString))
        {
            SqlHelper.PrepareCommand(sqlCommand, sqlConnection, null, cmdType, cmdText, commandParameters);
            int num = sqlCommand.ExecuteNonQuery();
            sqlCommand.Parameters.Clear();
            result = num;
        }
        return(result);
    }
コード例 #17
0
    public static object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
    {
        SqlCommand sqlCommand = new SqlCommand();
        object     result;

        using (SqlConnection sqlConnection = new SqlConnection(connectionString))
        {
            SqlHelper.PrepareCommand(sqlCommand, sqlConnection, null, cmdType, cmdText, commandParameters);
            object obj = sqlCommand.ExecuteScalar();
            sqlCommand.Parameters.Clear();
            result = obj;
        }
        return(result);
    }
コード例 #18
0
        /// <summary>
        /// reset warehouse inout
        /// <summary>
        /// <param name=id>id</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Reset(int id, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                modWarehouseProductTransfer mod = GetItem(id, out emsg);
                if (mod.Status == 0)
                {
                    emsg = "这张单据尚未审核,您无须重置";
                    return(false);
                }
                sql = string.Format("delete warehouse_product_inout where form_id='{0}' and (form_type='{1}' or form_type='{2}')", id, "转仓出库", "转仓入库");
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();

                sql = string.Format("update warehouse_product_transfer set status={0},audit_man='{1}',audit_time=null where id='{2}'", 0, updateuser, id);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
コード例 #19
0
        /// <summary>
        /// reset sales shipment
        /// <summary>
        /// <param name=formid>formid</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Reset(string formid, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                modAccCheckForm mod = GetItem(formid, out emsg);
                if (mod.Status == 0)
                {
                    emsg = "这张单据尚未审核,您无须重置";
                    return(false);
                }
                sql = string.Format("update acc_check_list set status=0,get_date=null where id={0}", mod.CheckId);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                sql = string.Format("update acc_check_form set status={0},audit_man='{1}',audit_time=getdate() where form_id='{2}'", 0, updateuser, formid);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
コード例 #20
0
    public static SqlDataReader ExecuteReader(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
    {
        SqlDataReader result;

        try
        {
            using (SqlCommand sqlCommand = new SqlCommand())
            {
                SqlHelper.PrepareCommand(sqlCommand, trans.Connection, trans, cmdType, cmdText, commandParameters);
                SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(CommandBehavior.Default);
                sqlCommand.Parameters.Clear();
                result = sqlDataReader;
            }
        }
        catch
        {
            throw;
        }
        return(result);
    }
コード例 #21
0
ファイル: FormMainDao.cs プロジェクト: icprog/HengDa
        void UpdateOne(SqlCommand cmd, HengDaEntity.FormMainOne _modelOne, StringBuilder strSql, SqlTransaction tran, SqlConnection conn)
        {
            strSql = new StringBuilder( );
            strSql.Append("UPDATE HDSHE SET ");
            strSql.Append("SHE004=@SHE004,");
            strSql.Append("SHE005=@SHE005,");
            strSql.Append("SHE006=@SHE006,");
            strSql.Append("SHE007=@SHE007,");
            strSql.Append("SHE008=@SHE008,");
            strSql.Append("SHE009=@SHE009");
            strSql.Append(" WHERE SHE001=@SHE001");
            strSql.Append(" AND SHE002=@SHE002");
            strSql.Append(" AND SHE003=@SHE003");
            SqlParameter[] parameter =
            {
                new SqlParameter("@SHE001", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHE002", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHE003", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHE004", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHE005", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHE006", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHE007", SqlDbType.Int),
                new SqlParameter("@SHE008", SqlDbType.Decimal,   6),
                new SqlParameter("@SHE009", SqlDbType.NVarChar, 255)
            };
            parameter[0].Value = _modelOne.SHE001;
            parameter[1].Value = _modelOne.SHE002;
            parameter[2].Value = _modelOne.SHE003;
            parameter[3].Value = _modelOne.SHE004;
            parameter[4].Value = _modelOne.SHE005;
            parameter[5].Value = _modelOne.SHE006;
            parameter[6].Value = _modelOne.SHE007;
            parameter[7].Value = _modelOne.SHE008;
            parameter[8].Value = _modelOne.SHE009;

            cmd.Parameters.Clear( );
            SqlHelper.PrepareCommand(cmd, conn, tran, strSql.ToString( ), parameter);
            cmd.CommandText = strSql.ToString( );
            cmd.ExecuteNonQuery( );
        }
コード例 #22
0
ファイル: FormMainDao.cs プロジェクト: icprog/HengDa
        void DeleteTwo(SqlCommand cmd, HengDaEntity.FormMainTwo _modelTwo, StringBuilder strSql, SqlTransaction tran, SqlConnection conn)
        {
            strSql = new StringBuilder( );
            strSql.Append("DELETE FROM HDSHF");
            strSql.Append(" WHERE SHF001=@SHF001");
            strSql.Append(" AND SHF002=@SHF002");
            strSql.Append(" AND SHF003=@SHF003");
            SqlParameter[] parameter =
            {
                new SqlParameter("@SHF001", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHF002", SqlDbType.NVarChar, 20),
                new SqlParameter("@SHF003", SqlDbType.NVarChar, 20)
            };
            parameter[0].Value = _modelTwo.SHF001;
            parameter[1].Value = _modelTwo.SHF002;
            parameter[2].Value = _modelTwo.SHF003;

            cmd.Parameters.Clear( );
            SqlHelper.PrepareCommand(cmd, conn, tran, strSql.ToString( ), parameter);
            cmd.CommandText = strSql.ToString( );
            cmd.ExecuteNonQuery( );
        }
コード例 #23
0
ファイル: FormMainDao.cs プロジェクト: icprog/HengDa
        void UpdateMain(SqlCommand cmd, HengDaEntity.FormMainHeader _modelHeader, StringBuilder strSql, SqlTransaction tran, SqlConnection conn)
        {
            strSql = new StringBuilder( );
            strSql.Append("UPDATE HDSHD SET ");
            strSql.Append("SHD002=@SHD002,");
            strSql.Append("SHD003=@SHD003,");
            strSql.Append("SHD004=@SHD004,");
            strSql.Append("SHD005=@SHD005,");
            strSql.Append("SHD006=@SHD006,");
            strSql.Append("SHD007=@SHD007,");
            strSql.Append("SHD008=@SHD008");
            strSql.Append(" WHERE SHD001=@SHD001");
            SqlParameter[] parameter =
            {
                new SqlParameter("@SHD001", SqlDbType.NVarChar,  20),
                new SqlParameter("@SHD002", SqlDbType.NVarChar,  20),
                new SqlParameter("@SHD003", SqlDbType.NVarChar,  20),
                new SqlParameter("@SHD004", SqlDbType.NVarChar,  20),
                new SqlParameter("@SHD005", SqlDbType.NVarChar,  20),
                new SqlParameter("@SHD006", SqlDbType.DateTime),
                new SqlParameter("@SHD007", SqlDbType.NVarChar,  20),
                new SqlParameter("@SHD008", SqlDbType.NVarChar, 20)
            };
            parameter[0].Value = _modelHeader.SHD001;
            parameter[1].Value = _modelHeader.SHD002;
            parameter[2].Value = _modelHeader.SHD003;
            parameter[3].Value = _modelHeader.SHD004;
            parameter[4].Value = _modelHeader.SHD005;
            parameter[5].Value = _modelHeader.SHD006;
            parameter[6].Value = _modelHeader.SHD007;
            parameter[7].Value = _modelHeader.SHD008;

            cmd.Parameters.Clear( );
            SqlHelper.PrepareCommand(cmd, conn, tran, strSql.ToString( ), parameter);
            cmd.CommandText = strSql.ToString( );
            cmd.ExecuteNonQuery( );
        }
コード例 #24
0
ファイル: DALACCRECEIVABLEFORM.cs プロジェクト: 100009/hberp
        /// <summary>
        /// audit
        /// <summary>
        /// <param name=id>id</param>
        /// <param name=updateuser>updateuser</param>
        /// <param name=out emsg>return error message</param>
        /// <returns>true/false</returns>
        public bool Audit(int id, string updateuser, out string emsg)
        {
            string        sql  = string.Empty;
            SqlConnection conn = SqlHelper.getConn();

            conn.Open();
            SqlTransaction trans = conn.BeginTransaction();
            SqlCommand     cmd   = new SqlCommand();

            try
            {
                string content           = string.Empty;
                string salesman          = string.Empty;
                string actioncode        = "GATHERING";
                int    adflag            = 1;
                modAccReceivableForm mod = GetItem(id, out emsg);
                if (mod.SubjectId.IndexOf("9135") == 0)
                {
                    actioncode = "BADDEBTS";
                    adflag     = -1;
                }

                dalCustomerList dalcust = new dalCustomerList();
                salesman = dalcust.GetSalesMan(mod.CustId);
                dalCustomerScoreRule dalcsr = new dalCustomerScoreRule();
                modCustomerScoreRule modcsr = dalcsr.GetItem(actioncode, out emsg);

                content = "科目:" + mod.SubjectName + "  实收金额:" + mod.GetMny + "  帐款金额:" + mod.ReceivableMny.ToString() + mod.Currency;

                sql = string.Format("update acc_receivable_form set status={0},audit_man='{1}',audit_time=getdate() where id={2}", 1, updateuser, id);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();

                sql = string.Format("insert into customer_log(cust_id,cust_name,action_code,action_type,action_man,form_id,action_subject,action_content,object_name,venue,from_time,to_time,scores,ad_flag,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',{12},{13},'{14}',getdate())", mod.CustId, mod.CustName, actioncode, "收货款", salesman, id, string.Empty, content, string.Empty, string.Empty, mod.FormDate, mod.FormDate, modcsr.Scores * mod.GetMny * mod.ExchangeRate, adflag, mod.UpdateUser);
                SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                cmd.ExecuteNonQuery();

                if (mod.ReceivableMny - mod.GetMny > 0)
                {
                    actioncode = "BADDEBTS";
                    modcsr     = dalcsr.GetItem(actioncode, out emsg);
                    content    = "折扣金额:" + (mod.ReceivableMny - mod.GetMny) + mod.Currency;
                    sql        = string.Format("insert into customer_log(cust_id,cust_name,action_code,action_type,action_man,form_id,action_subject,action_content,object_name,venue,from_time,to_time,scores,ad_flag,update_user,update_time)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',{12},{13},'{14}',getdate())", mod.CustId, mod.CustName, actioncode, "货款折扣", salesman, id, string.Empty, content, string.Empty, string.Empty, mod.FormDate, mod.FormDate, modcsr.Scores * (mod.ReceivableMny - mod.GetMny) * mod.ExchangeRate, -1, mod.UpdateUser);
                    SqlHelper.PrepareCommand(cmd, conn, trans, CommandType.Text, sql, null);
                    cmd.ExecuteNonQuery();
                }
                trans.Commit();
                emsg = string.Empty;
                return(true);
            }
            catch (Exception ex)
            {
                trans.Rollback();
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(false);
            }
            finally
            {
                trans.Dispose();
                cmd.Dispose();
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Dispose();
                }
            }
        }
コード例 #25
0
ファイル: LanDeOrderDao.cs プロジェクト: icprog/LanDe
        /// <summary>
        /// 录入一条记录
        /// </summary>
        /// <param name="_model"></param>
        /// <returns></returns>
        public bool InsertTran(LanDeLibrary.LanDeOrderEntity _model)
        {
            using (SqlConnection conn = new SqlConnection(SqlHelper.connstr))
            {
                conn.Open( );
                SqlCommand cmd = new SqlCommand( );
                cmd.Connection = conn;
                SqlTransaction tran = conn.BeginTransaction( );
                cmd.Transaction = tran;
                try
                {
                    StringBuilder strSql = new StringBuilder( );

                    //if ( DeleteExists ( _model . BGD006 ,_model . BGD030 ) )
                    //{
                    strSql.Append("UPDATE SGMBGD SET ");
                    strSql.Append("BGD023='F'");
                    strSql.AppendFormat(" WHERE BGD006=@BGD006");     // AND BGD030=CONVERT(INT,@BGD030)-10
                    SqlParameter [] paramet =
                    {
                        new SqlParameter("@BGD006", SqlDbType.NVarChar, 20)             //,
                        //new SqlParameter("@BGD030",SqlDbType.NVarChar,20)
                    };
                    paramet [0].Value = _model.BGD006;
                    //paramet [ 1 ] . Value = _model . BGD030;
                    //cmd . Parameters . Clear ( );
                    SqlHelper.PrepareCommand(cmd, conn, tran, strSql.ToString( ), paramet);
                    cmd.CommandText = strSql.ToString( );
                    cmd.ExecuteNonQuery( );
                    //}

                    SqlHelper.SaveLog(strSql.ToString( ), paramet);

                    strSql = new StringBuilder( );
                    strSql.Append("INSERT INTO SGMBGD ( ");
                    strSql.Append("BGD001,BGD002,BGD003,BGD004,BGD005,BGD006,BGD007,BGD008,BGD009,BGD010,BGD011,BGD012,BGD013,BGD014,BGD015,BGD016,BGD017,BGD018,BGD019,BGD020,BGD021,BGD022,BGD023,BGD024,BGD027,BGD030,BGD032,BGD033,BGD034,BGD035,BGD036)");
                    strSql.Append(" VALUES (@BGD001,@BGD002,@BGD003,@BGD004,@BGD005,@BGD006,@BGD007,@BGD008,@BGD009,@BGD010,@BGD011,@BGD012,@BGD013,@BGD014,@BGD015,@BGD016,@BGD017,@BGD018,@BGD019,@BGD020,@BGD021,@BGD022,@BGD023,@BGD024,@BGD027,@BGD030,@BGD032,@BGD033,@BGD034,@BGD035,@BGD036)");
                    SqlParameter [] parameter =
                    {
                        new SqlParameter("@BGD001", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD002", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD003", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD004", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD005", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD006", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD007", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD008", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD009", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD010", SqlDbType.Int),
                        new SqlParameter("@BGD011", SqlDbType.Int),
                        new SqlParameter("@BGD012", SqlDbType.Int),
                        new SqlParameter("@BGD013", SqlDbType.Int),
                        new SqlParameter("@BGD014", SqlDbType.Int),
                        new SqlParameter("@BGD015", SqlDbType.Int),
                        new SqlParameter("@BGD016", SqlDbType.Int),
                        new SqlParameter("@BGD017", SqlDbType.Int),
                        new SqlParameter("@BGD018", SqlDbType.Int),
                        new SqlParameter("@BGD019", SqlDbType.Int),
                        new SqlParameter("@BGD020", SqlDbType.Int),
                        new SqlParameter("@BGD021", SqlDbType.Int),
                        new SqlParameter("@BGD022", SqlDbType.Int),
                        new SqlParameter("@BGD023", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD024", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD027", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD030", SqlDbType.NVarChar,    20),
                        new SqlParameter("@BGD032", SqlDbType.DateTime),
                        new SqlParameter("@BGD033", SqlDbType.NVarChar,  3000),
                        new SqlParameter("@BGD034", SqlDbType.Date),
                        new SqlParameter("@BGD035", SqlDbType.NChar,       10),
                        new SqlParameter("@BGD036", SqlDbType.NChar, 10)
                    };
                    parameter [0].Value  = _model.BGD001;
                    parameter [1].Value  = _model.BGD002;
                    parameter [2].Value  = _model.BGD003;
                    parameter [3].Value  = _model.BGD004;
                    parameter [4].Value  = _model.BGD005;
                    parameter [5].Value  = _model.BGD006;
                    parameter [6].Value  = _model.BGD007;
                    parameter [7].Value  = _model.BGD008;
                    parameter [8].Value  = _model.BGD009;
                    parameter [9].Value  = _model.BGD010;
                    parameter [10].Value = _model.BGD011;
                    parameter [11].Value = _model.BGD012;
                    parameter [12].Value = _model.BGD013;
                    parameter [13].Value = _model.BGD014;
                    parameter [14].Value = _model.BGD015;
                    parameter [15].Value = _model.BGD016;
                    parameter [16].Value = _model.BGD017;
                    parameter [17].Value = _model.BGD018;
                    parameter [18].Value = _model.BGD019;
                    parameter [19].Value = _model.BGD020;
                    parameter [20].Value = _model.BGD021;
                    parameter [21].Value = _model.BGD022;
                    parameter [22].Value = _model.BGD023;
                    parameter [23].Value = _model.BGD024;
                    parameter [24].Value = _model.BGD027;
                    parameter [25].Value = _model.BGD030;
                    parameter [26].Value = _model.BGD032;
                    parameter [27].Value = _model.BGD033;
                    parameter [28].Value = _model.BGD034;
                    parameter [29].Value = _model.BGD035;
                    parameter [30].Value = _model.BGD036;

                    cmd.Parameters.Clear( );
                    SqlHelper.PrepareCommand(cmd, conn, tran, strSql.ToString( ), parameter);
                    cmd.CommandText = strSql.ToString( );
                    cmd.ExecuteNonQuery( );

                    SqlHelper.SaveLog(strSql.ToString( ), parameter);

                    DataTable tableQuery = GetData(_model.BGD006, _model.BGD004);
                    if (tableQuery != null && tableQuery.Rows.Count > 0)
                    {
                        _model.BGD018 += Convert.ToInt32(tableQuery.Rows [0] ["RAC008"].ToString( ));
                        _model.BGD010 += Convert.ToInt32(tableQuery.Rows [0] ["RAC009"].ToString( ));
                        _model.BGD011 += Convert.ToInt32(tableQuery.Rows [0] ["RAC026"].ToString( ));
                        _model.BGD012 += Convert.ToInt32(tableQuery.Rows [0] ["RAC980"].ToString( ));
                        _model.BGD013 += Convert.ToInt32(tableQuery.Rows [0] ["RAC981"].ToString( ));
                        _model.BGD014 += Convert.ToInt32(tableQuery.Rows [0] ["RAC982"].ToString( ));
                        _model.BGD015 += Convert.ToInt32(tableQuery.Rows [0] ["RAC983"].ToString( ));
                        _model.BGD016 += Convert.ToInt32(tableQuery.Rows [0] ["RAC984"].ToString( ));
                        _model.BGD017 += Convert.ToInt32(tableQuery.Rows [0] ["RAC985"].ToString( ));
                        _model.BGD019 += Convert.ToInt32(tableQuery.Rows [0] ["RAC960"].ToString( ));
                        _model.BGD020 += Convert.ToInt32(tableQuery.Rows [0] ["RAC961"].ToString( ));
                        _model.BGD021 += Convert.ToInt32(tableQuery.Rows [0] ["RAC962"].ToString( ));
                        _model.BGD022 += Convert.ToInt32(tableQuery.Rows [0] ["RAC963"].ToString( ));
                    }
                    StringBuilder strS = new StringBuilder( );
                    strS.Append("UPDATE SGMRAC SET ");
                    strS.Append("RAC008=@BGD018,");
                    strS.Append("RAC009=@BGD010,");
                    strS.Append("RAC010=@BGD026,");
                    strS.Append("RAC011=@BGD010,");
                    strS.Append("RAC026=@BGD011,");
                    strS.Append("RAC980=@BGD012,");
                    strS.Append("RAC981=@BGD013,");
                    strS.Append("RAC982=@BGD014,");
                    strS.Append("RAC983=@BGD015,");
                    strS.Append("RAC984=@BGD016,");
                    strS.Append("RAC985=@BGD017,");
                    strS.Append("RAC960=@BGD019,");
                    strS.Append("RAC961=@BGD020,");
                    strS.Append("RAC962=@BGD021,");
                    strS.Append("RAC963=@BGD022");
                    strS.Append(" WHERE RAC001=@BGD006 AND RAC002=@BGD030");
                    SqlParameter [] paramete =
                    {
                        new SqlParameter("@BGD010", SqlDbType.Int),
                        new SqlParameter("@BGD011", SqlDbType.Int),
                        new SqlParameter("@BGD012", SqlDbType.Int),
                        new SqlParameter("@BGD013", SqlDbType.Int),
                        new SqlParameter("@BGD014", SqlDbType.Int),
                        new SqlParameter("@BGD015", SqlDbType.Int),
                        new SqlParameter("@BGD016", SqlDbType.Int),
                        new SqlParameter("@BGD017", SqlDbType.Int),
                        new SqlParameter("@BGD018", SqlDbType.Int),
                        new SqlParameter("@BGD019", SqlDbType.Int),
                        new SqlParameter("@BGD020", SqlDbType.Int),
                        new SqlParameter("@BGD021", SqlDbType.Int),
                        new SqlParameter("@BGD022", SqlDbType.Int),
                        new SqlParameter("@BGD026", SqlDbType.NChar,    10),
                        new SqlParameter("@BGD006", SqlDbType.NVarChar, 20),
                        new SqlParameter("@BGD030", SqlDbType.NVarChar, 20)
                    };
                    paramete [0].Value  = _model.BGD010;
                    paramete [1].Value  = _model.BGD011;
                    paramete [2].Value  = _model.BGD012;
                    paramete [3].Value  = _model.BGD013;
                    paramete [4].Value  = _model.BGD014;
                    paramete [5].Value  = _model.BGD015;
                    paramete [6].Value  = _model.BGD016;
                    paramete [7].Value  = _model.BGD017;
                    paramete [8].Value  = _model.BGD018;
                    paramete [9].Value  = _model.BGD019;
                    paramete [10].Value = _model.BGD020;
                    paramete [11].Value = _model.BGD021;
                    paramete [12].Value = _model.BGD022;
                    paramete [13].Value = _model.BGD026;
                    paramete [14].Value = _model.BGD006;
                    paramete [15].Value = _model.BGD030;
                    cmd.Parameters.Clear( );
                    SqlHelper.PrepareCommand(cmd, conn, tran, strS.ToString( ), paramete);
                    cmd.CommandText = strS.ToString( );
                    cmd.ExecuteNonQuery( );

                    SqlHelper.SaveLog(strS.ToString( ), paramete);

                    tran.Commit( );
                    return(true);
                }
                catch
                {
                    tran.Rollback( );
                    return(false);
                }
                finally
                {
                    cmd.Dispose( );
                    conn.Close( );
                }
            }
        }
コード例 #26
0
ファイル: LanDeOrderDao.cs プロジェクト: icprog/LanDe
        /// <summary>
        /// 编辑一条记录
        /// </summary>
        /// <param name="_model"></param>
        /// <returns></returns>
        public bool UpdateTrans(LanDeLibrary.LanDeOrderEntity _model)
        {
            using (SqlConnection conn = new SqlConnection(SqlHelper.connstr))
            {
                conn.Open( );
                SqlCommand cmd = new SqlCommand( );
                cmd.Connection = conn;
                SqlTransaction tran = conn.BeginTransaction( );
                cmd.Transaction = tran;
                try
                {
                    StringBuilder strSql = new StringBuilder( );
                    strSql.Append("UPDATE SGMBGD SET ");
                    strSql.Append("BGD001=@BGD001,");
                    strSql.Append("BGD002=@BGD002,");
                    strSql.Append("BGD003=@BGD003,");
                    strSql.Append("BGD004=@BGD004,");
                    strSql.Append("BGD005=@BGD005,");
                    strSql.Append("BGD007=@BGD007,");
                    strSql.Append("BGD008=@BGD008,");
                    strSql.Append("BGD009=@BGD009,");
                    strSql.Append("BGD010=@BGD010,");
                    strSql.Append("BGD011=@BGD011,");
                    strSql.Append("BGD012=@BGD012,");
                    strSql.Append("BGD013=@BGD013,");
                    strSql.Append("BGD014=@BGD014,");
                    strSql.Append("BGD015=@BGD015,");
                    strSql.Append("BGD016=@BGD016,");
                    strSql.Append("BGD017=@BGD017,");
                    strSql.Append("BGD018=@BGD018,");
                    strSql.Append("BGD019=@BGD019,");
                    strSql.Append("BGD020=@BGD020,");
                    strSql.Append("BGD021=@BGD021,");
                    strSql.Append("BGD022=@BGD022,");
                    //strSql.Append( "BGD023=@BGD023,"  );
                    strSql.Append("BGD024=@BGD024,");
                    strSql.Append("BGD027=@BGD027,");
                    //strSql.Append( "BGD032=@BGD032," );
                    strSql.Append("BGD033=@BGD033,");
                    strSql.Append("BGD035=@BGD035,");
                    strSql.Append("BGD036=@BGD036");
                    strSql.Append(" WHERE BGD006=@BGD006 AND BGD030=@BGD030");
                    SqlParameter[] parameter =
                    {
                        new SqlParameter("@BGD001", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD002", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD003", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD004", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD005", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD006", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD007", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD008", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD009", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD010", SqlDbType.Int),
                        new SqlParameter("@BGD011", SqlDbType.Int),
                        new SqlParameter("@BGD012", SqlDbType.Int),
                        new SqlParameter("@BGD013", SqlDbType.Int),
                        new SqlParameter("@BGD014", SqlDbType.Int),
                        new SqlParameter("@BGD015", SqlDbType.Int),
                        new SqlParameter("@BGD016", SqlDbType.Int),
                        new SqlParameter("@BGD017", SqlDbType.Int),
                        new SqlParameter("@BGD018", SqlDbType.Int),
                        new SqlParameter("@BGD019", SqlDbType.Int),
                        new SqlParameter("@BGD020", SqlDbType.Int),
                        new SqlParameter("@BGD021", SqlDbType.Int),
                        new SqlParameter("@BGD022", SqlDbType.Int),
                        //new SqlParameter("@BGD023",SqlDbType.NVarChar,20),
                        new SqlParameter("@BGD024", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD027", SqlDbType.NVarChar,   20),
                        new SqlParameter("@BGD030", SqlDbType.NVarChar,   20),
                        //new SqlParameter("@BGD032",SqlDbType.DateTime),
                        new SqlParameter("@BGD033", SqlDbType.NVarChar, 3000),
                        //new SqlParameter("@BGD034",SqlDbType.Date),
                        new SqlParameter("@BGD035", SqlDbType.NChar,      10),
                        new SqlParameter("@BGD036", SqlDbType.NChar, 10)
                    };
                    parameter[0].Value  = _model.BGD001;
                    parameter[1].Value  = _model.BGD002;
                    parameter[2].Value  = _model.BGD003;
                    parameter[3].Value  = _model.BGD004;
                    parameter[4].Value  = _model.BGD005;
                    parameter[5].Value  = _model.BGD006;
                    parameter[6].Value  = _model.BGD007;
                    parameter[7].Value  = _model.BGD008;
                    parameter[8].Value  = _model.BGD009;
                    parameter[9].Value  = _model.BGD010;
                    parameter[10].Value = _model.BGD011;
                    parameter[11].Value = _model.BGD012;
                    parameter[12].Value = _model.BGD013;
                    parameter[13].Value = _model.BGD014;
                    parameter[14].Value = _model.BGD015;
                    parameter[15].Value = _model.BGD016;
                    parameter[16].Value = _model.BGD017;
                    parameter[17].Value = _model.BGD018;
                    parameter[18].Value = _model.BGD019;
                    parameter[19].Value = _model.BGD020;
                    parameter[20].Value = _model.BGD021;
                    parameter[21].Value = _model.BGD022;
                    //parameter[22].Value = _model.BGD023;
                    parameter[22].Value = _model.BGD024;
                    parameter[23].Value = _model.BGD027;
                    parameter[24].Value = _model.BGD030;
                    //parameter[25].Value = _model.BGD032;
                    parameter[25].Value = _model.BGD033;
                    //parameter[28].Value = _model.BGD034;
                    parameter[26].Value = _model.BGD035;
                    parameter[27].Value = _model.BGD036;

                    SqlHelper.PrepareCommand(cmd, conn, tran, strSql.ToString( ), parameter);
                    cmd.CommandText = strSql.ToString( );
                    cmd.ExecuteNonQuery( );

                    SqlHelper.SaveLog(strSql.ToString( ), parameter);

                    StringBuilder strS = new StringBuilder( );
                    strS.Append("UPDATE SGMRAC SET ");
                    strS.Append("RAC008=@BGD018,");  //投入
                    strS.Append("RAC009=@BGD010,");  //产出
                    strS.Append("RAC010=@BGD026,");  //在制
                    strS.Append("RAC011=@BGD010,");
                    strS.Append("RAC026=@BGD011,");
                    strS.Append("RAC980=@BGD012,");
                    strS.Append("RAC981=@BGD013,");
                    strS.Append("RAC982=@BGD014,");
                    strS.Append("RAC983=@BGD015,");
                    strS.Append("RAC984=@BGD016,");
                    strS.Append("RAC985=@BGD017,");
                    strS.Append("RAC960=@BGD019,");
                    strS.Append("RAC961=@BGD020,");
                    strS.Append("RAC962=@BGD021,");
                    strS.Append("RAC963=@BGD022");
                    strS.Append(" WHERE RAC001=@BGD006 AND RAC002=@BGD030");
                    SqlParameter[] paramete =
                    {
                        new SqlParameter("@BGD010", SqlDbType.Int),
                        new SqlParameter("@BGD011", SqlDbType.Int),
                        new SqlParameter("@BGD012", SqlDbType.Int),
                        new SqlParameter("@BGD013", SqlDbType.Int),
                        new SqlParameter("@BGD014", SqlDbType.Int),
                        new SqlParameter("@BGD015", SqlDbType.Int),
                        new SqlParameter("@BGD016", SqlDbType.Int),
                        new SqlParameter("@BGD017", SqlDbType.Int),
                        new SqlParameter("@BGD018", SqlDbType.Int),
                        new SqlParameter("@BGD019", SqlDbType.Int),
                        new SqlParameter("@BGD020", SqlDbType.Int),
                        new SqlParameter("@BGD021", SqlDbType.Int),
                        new SqlParameter("@BGD022", SqlDbType.Int),
                        new SqlParameter("@BGD026", SqlDbType.NChar,    10),
                        new SqlParameter("@BGD006", SqlDbType.NVarChar, 20),
                        new SqlParameter("@BGD030", SqlDbType.NVarChar, 20)
                    };
                    paramete[0].Value  = _model.BGD010;
                    paramete[1].Value  = _model.BGD011;
                    paramete[2].Value  = _model.BGD012;
                    paramete[3].Value  = _model.BGD013;
                    paramete[4].Value  = _model.BGD014;
                    paramete[5].Value  = _model.BGD015;
                    paramete[6].Value  = _model.BGD016;
                    paramete[7].Value  = _model.BGD017;
                    paramete[8].Value  = _model.BGD018;
                    paramete[9].Value  = _model.BGD019;
                    paramete[10].Value = _model.BGD020;
                    paramete[11].Value = _model.BGD021;
                    paramete[12].Value = _model.BGD022;
                    paramete[13].Value = _model.BGD026;
                    paramete[14].Value = _model.BGD006;
                    paramete[15].Value = _model.BGD030;
                    cmd.Parameters.Clear( );
                    SqlHelper.PrepareCommand(cmd, conn, tran, strS.ToString( ), paramete);
                    cmd.CommandText = strS.ToString( );
                    cmd.ExecuteNonQuery( );

                    SqlHelper.SaveLog(strS.ToString( ), paramete);

                    tran.Commit( );
                    return(true);
                }
                catch
                {
                    tran.Rollback( );
                    return(false);
                }
                finally
                {
                    cmd.Dispose( );
                    conn.Close( );
                }
            }
        }