Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DigiPower.Onlinecol.Standard.Model.T_Report_MainSql_MDL model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Report_MainSql(");
            strSql.Append("ReportID,MainSql,OrderId,IsValid,OtherName)");
            strSql.Append(" values (");
            strSql.Append("@ReportID,@MainSql,@OrderId,@IsValid,@OtherName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ReportID",  SqlDbType.Int,       8),
                new SqlParameter("@MainSql",   SqlDbType.VarChar, 500),
                new SqlParameter("@OrderId",   SqlDbType.Int,       8),
                new SqlParameter("@IsValid",   SqlDbType.Bit,       1),
                new SqlParameter("@OtherName", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.ReportID;
            parameters[1].Value = model.MainSql;
            parameters[2].Value = model.OrderId;
            parameters[3].Value = model.IsValid;
            parameters[4].Value = model.OtherName;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(DigiPower.Onlinecol.Standard.Model.T_Report_MainSql_MDL model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Report_MainSql set ");
            strSql.Append("ReportID=@ReportID,");
            strSql.Append("MainSql=@MainSql,");
            strSql.Append("OrderId=@OrderId,");
            strSql.Append("IsValid=@IsValid,");
            strSql.Append("OtherName=@OtherName");
            strSql.Append(" where ReportMainSqlID=@ReportMainSqlID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ReportMainSqlID", SqlDbType.Int,       8),
                new SqlParameter("@ReportID",        SqlDbType.Int,       8),
                new SqlParameter("@MainSql",         SqlDbType.VarChar, 500),
                new SqlParameter("@OrderId",         SqlDbType.Int,       8),
                new SqlParameter("@IsValid",         SqlDbType.Bit,       1),
                new SqlParameter("@OtherName",       SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.ReportMainSqlID;
            parameters[1].Value = model.ReportID;
            parameters[2].Value = model.MainSql;
            parameters[3].Value = model.OrderId;
            parameters[4].Value = model.IsValid;
            parameters[5].Value = model.OtherName;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DigiPower.Onlinecol.Standard.Model.T_Report_MainSql_MDL GetModel(int ReportMainSqlID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ReportMainSqlID,ReportID,MainSql,OrderId,IsValid,OtherName from T_Report_MainSql ");
            strSql.Append(" where ReportMainSqlID=@ReportMainSqlID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ReportMainSqlID", SqlDbType.Int, 8)
            };
            parameters[0].Value = ReportMainSqlID;

            DigiPower.Onlinecol.Standard.Model.T_Report_MainSql_MDL model = new DigiPower.Onlinecol.Standard.Model.T_Report_MainSql_MDL();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ReportMainSqlID"].ToString() != "")
                {
                    model.ReportMainSqlID = int.Parse(ds.Tables[0].Rows[0]["ReportMainSqlID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ReportID"].ToString() != "")
                {
                    model.ReportID = int.Parse(ds.Tables[0].Rows[0]["ReportID"].ToString());
                }
                model.MainSql = ds.Tables[0].Rows[0]["MainSql"].ToString();
                if (ds.Tables[0].Rows[0]["OrderId"].ToString() != "")
                {
                    model.OrderId = int.Parse(ds.Tables[0].Rows[0]["OrderId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsValid"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsValid"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsValid"].ToString().ToLower() == "true"))
                    {
                        model.IsValid = true;
                    }
                    else
                    {
                        model.IsValid = false;
                    }
                }
                model.OtherName = ds.Tables[0].Rows[0]["OtherName"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }