コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(DTcms.Model.ReceivedUnitPrice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ReceivedUnitPrice(");
            strSql.Append("ReceivedMoneyId,BeginTime,Price,EndTime,Remark");
            strSql.Append(") values (");
            strSql.Append("@ReceivedMoneyId,@BeginTime,@Price,@EndTime,@Remark");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ReceivedMoneyId", SqlDbType.Int,       4),
                new SqlParameter("@BeginTime",       SqlDbType.DateTime),
                new SqlParameter("@Price",           SqlDbType.Decimal,   9),
                new SqlParameter("@EndTime",         SqlDbType.DateTime),
                new SqlParameter("@Remark",          SqlDbType.VarChar, 254)
            };

            parameters[0].Value = model.ReceivedMoneyId;
            parameters[1].Value = model.BeginTime;
            parameters[2].Value = model.Price;
            parameters[3].Value = model.EndTime;
            parameters[4].Value = model.Remark;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DTcms.Model.ReceivedUnitPrice GetModel(int ReceivedMoneyId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ReceivedMoneyId, BeginTime, Price, EndTime, Remark  ");
            strSql.Append("  from ReceivedUnitPrice ");
            strSql.Append(" where ReceivedMoneyId=@ReceivedMoneyId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ReceivedMoneyId", SqlDbType.Int, 4)
            };
            parameters[0].Value = ReceivedMoneyId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ReceivedMoneyId"].ToString() != "")
                {
                    model.ReceivedMoneyId = int.Parse(ds.Tables[0].Rows[0]["ReceivedMoneyId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BeginTime"].ToString() != "")
                {
                    model.BeginTime = DateTime.Parse(ds.Tables[0].Rows[0]["BeginTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price"].ToString() != "")
                {
                    model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EndTime"].ToString() != "")
                {
                    model.EndTime = DateTime.Parse(ds.Tables[0].Rows[0]["EndTime"].ToString());
                }
                model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.ReceivedUnitPrice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ReceivedUnitPrice set ");

            strSql.Append(" ReceivedMoneyId = @ReceivedMoneyId , ");
            strSql.Append(" BeginTime = @BeginTime , ");
            strSql.Append(" Price = @Price , ");
            strSql.Append(" EndTime = @EndTime , ");
            strSql.Append(" Remark = @Remark  ");
            strSql.Append(" where ReceivedMoneyId=@ReceivedMoneyId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ReceivedMoneyId", SqlDbType.Int,       4),
                new SqlParameter("@BeginTime",       SqlDbType.DateTime),
                new SqlParameter("@Price",           SqlDbType.Decimal,   9),
                new SqlParameter("@EndTime",         SqlDbType.DateTime),
                new SqlParameter("@Remark",          SqlDbType.VarChar, 254)
            };

            parameters[0].Value = model.ReceivedMoneyId;
            parameters[1].Value = model.BeginTime;
            parameters[2].Value = model.Price;
            parameters[3].Value = model.EndTime;
            parameters[4].Value = model.Remark;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
ファイル: ReceivedUnitPrice.cs プロジェクト: uwitec/MWMS
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DTcms.Model.ReceivedUnitPrice GetModel(int ReceivedMoneyId)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select ReceivedMoneyId, BeginTime, Price, EndTime, Remark  ");
            strSql.Append("  from ReceivedUnitPrice ");
            strSql.Append(" where ReceivedMoneyId=@ReceivedMoneyId ");
                        SqlParameter[] parameters = {
                    new SqlParameter("@ReceivedMoneyId", SqlDbType.Int,4)			};
            parameters[0].Value = ReceivedMoneyId;

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

            if(ds.Tables[0].Rows.Count>0)
            {
                                                if(ds.Tables[0].Rows[0]["ReceivedMoneyId"].ToString()!="")
                {
                    model.ReceivedMoneyId=int.Parse(ds.Tables[0].Rows[0]["ReceivedMoneyId"].ToString());
                }
                                                                                                                                if(ds.Tables[0].Rows[0]["BeginTime"].ToString()!="")
                {
                    model.BeginTime=DateTime.Parse(ds.Tables[0].Rows[0]["BeginTime"].ToString());
                }
                                                                                                                                if(ds.Tables[0].Rows[0]["Price"].ToString()!="")
                {
                    model.Price=decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
                }
                                                                                                                                if(ds.Tables[0].Rows[0]["EndTime"].ToString()!="")
                {
                    model.EndTime=DateTime.Parse(ds.Tables[0].Rows[0]["EndTime"].ToString());
                }
                                                                                                                                                model.Remark= ds.Tables[0].Rows[0]["Remark"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }