Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Tunnel.Model.Tunnel_ProjectReport model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Tunnel_ProjectReport set ");
            strSql.Append("Report_Name=@Report_Name,");
            strSql.Append("Report_Class=@Report_Class,");
            strSql.Append("Report_Sort=@Report_Sort,");
            strSql.Append("Report_State=@Report_State,");
            strSql.Append("Report_Shen=@Report_Shen,");
            strSql.Append("Report_Order=@Report_Order,");
            strSql.Append("Report_UserID=@Report_UserID");
            strSql.Append(" where Report_Id=@Report_Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Report_Id",     SqlDbType.Int,       4),
                new SqlParameter("@Report_Name",   SqlDbType.VarChar, 200),
                new SqlParameter("@Report_Class",  SqlDbType.Int,       4),
                new SqlParameter("@Report_Sort",   SqlDbType.Int,       4),
                new SqlParameter("@Report_State",  SqlDbType.Int,       4),
                new SqlParameter("@Report_Shen",   SqlDbType.Int,       4),
                new SqlParameter("@Report_Order",  SqlDbType.Int,       4),
                new SqlParameter("@Report_UserID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Report_Id;
            parameters[1].Value = model.Report_Name;
            parameters[2].Value = model.Report_Class;
            parameters[3].Value = model.Report_Sort;
            parameters[4].Value = model.Report_State;
            parameters[5].Value = model.Report_Shen;
            parameters[6].Value = model.Report_Order;
            parameters[7].Value = model.Report_UserID;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Example #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Tunnel.Model.Tunnel_ProjectReport GetModel(int Report_Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Report_Id,Report_Name,Report_Class,Report_Sort,Report_State,Report_Shen,Report_Order,Report_UserID from Tunnel_ProjectReport ");
            strSql.Append(" where Report_Id=@Report_Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Report_Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Report_Id;

            Tunnel.Model.Tunnel_ProjectReport model = new Tunnel.Model.Tunnel_ProjectReport();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Report_Id"].ToString() != "")
                {
                    model.Report_Id = int.Parse(ds.Tables[0].Rows[0]["Report_Id"].ToString());
                }
                model.Report_Name = ds.Tables[0].Rows[0]["Report_Name"].ToString();
                if (ds.Tables[0].Rows[0]["Report_Class"].ToString() != "")
                {
                    model.Report_Class = int.Parse(ds.Tables[0].Rows[0]["Report_Class"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Report_Sort"].ToString() != "")
                {
                    model.Report_Sort = int.Parse(ds.Tables[0].Rows[0]["Report_Sort"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Report_State"].ToString() != "")
                {
                    model.Report_State = int.Parse(ds.Tables[0].Rows[0]["Report_State"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Report_Shen"].ToString() != "")
                {
                    model.Report_Shen = int.Parse(ds.Tables[0].Rows[0]["Report_Shen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Report_Order"].ToString() != "")
                {
                    model.Report_Order = int.Parse(ds.Tables[0].Rows[0]["Report_Order"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Report_UserID"].ToString() != "")
                {
                    model.Report_UserID = int.Parse(ds.Tables[0].Rows[0]["Report_UserID"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Tunnel.Model.Tunnel_ProjectReport model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Tunnel_ProjectReport(");
            strSql.Append("Report_Name,Report_Class,Report_Sort,Report_State,Report_Shen,Report_Order,Report_UserID)");
            strSql.Append(" values (");
            strSql.Append("@Report_Name,@Report_Class,@Report_Sort,@Report_State,@Report_Shen,@Report_Order,@Report_UserID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Report_Name",   SqlDbType.VarChar, 200),
                new SqlParameter("@Report_Class",  SqlDbType.Int,       4),
                new SqlParameter("@Report_Sort",   SqlDbType.Int,       4),
                new SqlParameter("@Report_State",  SqlDbType.Int,       4),
                new SqlParameter("@Report_Shen",   SqlDbType.Int,       4),
                new SqlParameter("@Report_Order",  SqlDbType.Int,       4),
                new SqlParameter("@Report_UserID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Report_Name;
            parameters[1].Value = model.Report_Class;
            parameters[2].Value = model.Report_Sort;
            parameters[3].Value = model.Report_State;
            parameters[4].Value = model.Report_Shen;
            parameters[5].Value = model.Report_Order;
            parameters[6].Value = model.Report_UserID;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }