Beispiel #1
0
 /// <summary>
 /// 以事务方式执行拼接好的sql语句组
 /// </summary>
 public static void RunSqlStatement()
 {
     BaseSQL.ExecuteSqlTran(strSqlLlist);
     IDataParameter[] parameters = new System.Data.IDataParameter[1];  //实例化参数对象
     parameters[0] = new SqlParameter("@returnMessage", string.Empty); //参数对象赋值
     BaseSQL.RunProcedure("FrmRight_RefreshButtonInfo", parameters);   //执行存储过程,刷新button相关表
 }
Beispiel #2
0
        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="strQuerySqlId">查询ID</param>
        /// <param name="strControlTmp">控件列表变量</param>
        /// <returns></returns>
        public static DataSet ExecUserProcedure(string strQuerySqlId, string[,] strControlTmp)
        {
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            dt = GetUserQueryInfo(strQuerySqlId);
            if (!string.IsNullOrEmpty(dt.Rows[0].ItemArray[6].ToString().Trim()))
            {
                int intRowCount             = dt.Rows.Count;
                IDataParameter[] parameters = new System.Data.IDataParameter[intRowCount];//实例化参数对象
                for (int i = 0; i < intRowCount; i++)
                {
                    //string reval = string.Empty;
                    string strParaName = dt.Rows[i].ItemArray[6].ToString();
                    switch (strControlTmp[i, 2].ToLower())
                    {
                    case "int":
                        //reval = "Int32";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Int);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToInt32(strControlTmp[i, 1]);
                        break;

                    case "text":
                        //reval = "String";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Text);//参数对象赋值
                        parameters[i].Value = Convert.ToString(strControlTmp[i, 1]);
                        break;

                    case "bigint":
                        //reval = "Int64";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.BigInt);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToInt64(strControlTmp[i, 1]);
                        break;

                    case "binary":
                        //reval = "System.Byte[]";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Binary);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToByte(strControlTmp[i, 1]);
                        break;

                    case "bit":
                        //reval = "Boolean";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Bit);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToBoolean(strControlTmp[i, 1]);
                        break;

                    case "char":
                        //reval = "String";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Char);//参数对象赋值
                        parameters[i].Value = Convert.ToString(strControlTmp[i, 1]);
                        break;

                    case "datetime":
                        //reval = "System.DateTime";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.DateTime);//参数对象赋值
                        parameters[i].Value = Convert.ToDateTime(strControlTmp[i, 1]);
                        break;

                    case "decimal":
                        //reval = "System.Decimal";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Decimal);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToDecimal(strControlTmp[i, 1]);
                        break;

                    case "float":
                        //reval = "System.Double";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Float);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToDouble(strControlTmp[i, 1]);
                        break;

                    case "image":
                        //reval = "System.Byte[]";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Image);//参数对象赋值
                        parameters[i].Value = Convert.ToByte(strControlTmp[i, 1]);
                        break;

                    case "money":
                        //reval = "System.Decimal";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Money);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToDecimal(strControlTmp[i, 1]);
                        break;

                    case "nchar":
                        //reval = "String";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.NChar);//参数对象赋值
                        parameters[i].Value = Convert.ToString(strControlTmp[i, 1]);
                        break;

                    case "ntext":
                        //reval = "String";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.NText);//参数对象赋值
                        parameters[i].Value = Convert.ToString(strControlTmp[i, 1]);
                        break;

                    case "numeric":
                        //reval = "System.Decimal";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Decimal);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToDecimal(strControlTmp[i, 1]);
                        break;

                    case "nvarchar":
                        //reval = "String";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.NVarChar);//参数对象赋值
                        parameters[i].Value = Convert.ToString(strControlTmp[i, 1]);
                        break;

                    case "real":
                        //reval = "System.Single";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Real);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToSingle(strControlTmp[i, 1]);
                        break;

                    case "smalldatetime":
                        //reval = "System.DateTime";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.SmallDateTime);//参数对象赋值
                        parameters[i].Value = Convert.ToDateTime(strControlTmp[i, 1]);
                        break;

                    case "smallint":
                        //reval = "Int16";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.SmallInt);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToInt16(strControlTmp[i, 1]);
                        break;

                    case "smallmoney":
                        //reval = "System.Decimal";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.SmallMoney);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToDecimal(strControlTmp[i, 1]);
                        break;

                    case "timestamp":
                        //reval = "System.DateTime";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Timestamp);//参数对象赋值
                        parameters[i].Value = Convert.ToDateTime(strControlTmp[i, 1]);
                        break;

                    case "tinyint":
                        //reval = "System.Byte";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.TinyInt);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToByte(strControlTmp[i, 1]);
                        break;

                    case "varbinary":
                        //reval = "System.Byte[]";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.VarBinary);//参数对象赋值
                        parameters[i].Value = string.IsNullOrEmpty(strControlTmp[i, 1]) ? null : (object)Convert.ToByte(strControlTmp[i, 1]);
                        break;

                    case "varchar":
                        //reval = "String";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.VarChar);//参数对象赋值
                        parameters[i].Value = Convert.ToString(strControlTmp[i, 1]);
                        break;

                    case "Variant":
                        //reval = "Object";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.Variant);//参数对象赋值
                        parameters[i].Value = (object)(strControlTmp[i, 1]);
                        break;

                    default:
                        //reval = "String";
                        parameters[i]       = new SqlParameter(strParaName, SqlDbType.VarChar);//参数对象赋值
                        parameters[i].Value = Convert.ToString(strControlTmp[i, 1]);
                        break;
                    }
                }
                ds = BaseSQL.RunProcedure(Convert.ToString(dt.Rows[0].ItemArray[3]).Trim(), parameters, "dd");//执行存储过程
                return(ds);
            }
            return(null);
        }