예제 #1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update1(baozhuang_chuhuo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update baozhuang_chuhuo set ");
            strSql.Append("备货单=@备货单,");
            strSql.Append("出货日期=@出货日期,");
            strSql.Append("出货数量=@出货数量");
            strSql.Append(" where 备货单=@备货单 and 出货日期=@出货日期");
            SqlParameter[] parameters =
            {
                new SqlParameter("@备货单",  SqlDbType.NVarChar,  20),
                new SqlParameter("@出货日期", SqlDbType.DateTime),
                new SqlParameter("@出货数量", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.备货单;
            parameters[1].Value = model.出货日期;
            parameters[2].Value = model.出货数量;
            int rows = dbhelper1.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 根据备货单号,入库时间查询一条记录
        /// </summary>
        /// <param name="sId"></param>
        /// <returns></returns>
        public baozhuang_chuhuo GetModels(string 备货单号, DateTime 入库时间)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 备货单,出货日期,出货数量 from baozhuang_chuhuo ");
            strSql.Append(" where 备货单=@备货单号 and 出货日期=@入库时间");
            SqlParameter[] parameters =
            {
                new SqlParameter("@备货单号", SqlDbType.NVarChar, 25),
                new SqlParameter("@入库时间", SqlDbType.DateTime, 10)
            };
            parameters[0].Value = 备货单号;
            parameters[1].Value = 入库时间;

            baozhuang_chuhuo model = new baozhuang_chuhuo();
            DataSet          ds    = dbhelper1.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public baozhuang_chuhuo DataRowToModel(DataRow row)
        {
            baozhuang_chuhuo model = new baozhuang_chuhuo();

            if (row != null)
            {
                if (row["备货单"] != null)
                {
                    model.备货单 = row["备货单"].ToString();
                }
                if (row["出货日期"] != null)
                {
                    model.出货日期 = row["出货日期"].ToString();
                }
                if (row["出货数量"] != null && row["出货数量"].ToString() != "")
                {
                    model.出货数量 = int.Parse(row["出货数量"].ToString());
                }
            }
            return(model);
        }