Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZhangWei.Model.HasChecked model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update HasChecked set ");
            strSql.Append("Month=@Month");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Month", SqlDbType.DateTime),
                new SqlParameter("@ID",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Month;
            parameters[1].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZhangWei.Model.HasChecked GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Month from HasChecked ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Month"] != null && ds.Tables[0].Rows[0]["Month"].ToString() != "")
                {
                    model.Month = DateTime.Parse(ds.Tables[0].Rows[0]["Month"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ZhangWei.Model.HasChecked model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into HasChecked(");
            strSql.Append("Month)");
            strSql.Append(" values (");
            strSql.Append("@Month)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Month", SqlDbType.DateTime)
            };
            parameters[0].Value = model.Month;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        private string StockToExcel(Int32 StoreHouse_ID)
        {
            DataSet ds      = new ZhangWei.BLL.StockPile().CheckStock(StoreHouse_ID);
            string  ToExcel = new LTP.Common.DataToExcel().OutputExcel(ds.Tables[0], "库存盘点 " + DateTime.Now.ToString(), HttpContext.Current.Server.MapPath("/ExcelFiles/"), "库存盘点");

            ZhangWei.BLL.HasChecked   bl_hc = new ZhangWei.BLL.HasChecked();
            ZhangWei.Model.HasChecked ml_hc = bl_hc.GetModel(bl_hc.GetMaxId() - 1);
            DateTime dt            = DateTime.Now;
            DateTime LastCheckTime = ml_hc.Month;

            if (dt.Month > LastCheckTime.Month)
            {
                ml_hc.Month = dt;
                bl_hc.Add(ml_hc);
            }
            else
            {
                ml_hc.Month = dt;
                bl_hc.Update(ml_hc);
            }
            return(ToExcel);
        }