Exemplo n.º 1
0
        /// <summary>
        /// 获取符合条件自动出库库存列表
        /// </summary>
        /// <param name="productStatus">物料状态</param>
        /// <param name="timeInterval">当前时间减去更新时间的时间差(单位小时)</param>
        /// <returns></returns>
        public DataTable GetTimeArriveModelList(string productStatus, int timeInterval, Dictionary <string, List <string> > outStorageBatchDic)
        {
            if (outStorageBatchDic == null || outStorageBatchDic.Count == 0)
            {
                return(null);
            }
            string batchNumSqlA1 = "";
            string batchNumSqlB1 = "";

            for (int i = 0; i < outStorageBatchDic.Keys.Count; i++)
            {
                string        houseName   = outStorageBatchDic.Keys.ElementAt(i);
                List <string> batchesList = outStorageBatchDic[houseName];
                switch (houseName)
                {
                case "A1库房":
                    for (int a = 0; a < batchesList.Count; a++)
                    {
                        if (a == 0)
                        {
                            batchNumSqlA1 += "(ProductBatchNum ='" + batchesList[a] + "'";
                        }
                        else
                        {
                            batchNumSqlA1 += "or ProductBatchNum='" + batchesList[a] + "'";
                        }
                    }
                    batchNumSqlA1 += "and StoreHouseName = '" + houseName + "')";
                    break;

                case "B1库房":
                    for (int b = 0; b < batchesList.Count; b++)
                    {
                        if (b == 0)
                        {
                            batchNumSqlB1 += "(ProductBatchNum ='" + batchesList[b] + "'";
                        }
                        else
                        {
                            batchNumSqlB1 += "or ProductBatchNum='" + batchesList[b] + "'";
                        }
                    }
                    batchNumSqlB1 += "and StoreHouseName = '" + houseName + "')";
                    break;
                }
            }
            string        dtNow  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd");
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT  StockList .*  FROM GoodsSite INNER JOIN Stock ON GoodsSite.GoodsSiteID = Stock.GoodsSiteID INNER JOIN StockList ON Stock.StockID = StockList.StockID ");
            strSql.Append(" where  GoodsSiteStoreStatus='有货' and GoodsSiteRunStatus = '任务完成' and");
            strSql.Append(" ProductStatus = '" + productStatus + "' and datediff(hour,UpdateTime,'" + dtNow + "') >=" + timeInterval
                          + " and UpdateTime != '' and (" + batchNumSqlA1 + "or" + batchNumSqlB1 + ")");

            StockListModel model = new StockListModel();
            DataSet        ds    = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(ds.Tables[0]);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(StockListModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update StockList set ");
            strSql.Append("ManaTaskID=@ManaTaskID,");
            strSql.Append("StoreHouseName=@StoreHouseName,");
            strSql.Append("StockID=@StockID,");
            strSql.Append("ProductCode=@ProductCode,");
            strSql.Append("ProductNum=@ProductNum,");
            strSql.Append("ProductStatus=@ProductStatus,");
            strSql.Append("ProductFrameCode=@ProductFrameCode,");
            strSql.Append("ProductName=@ProductName,");
            strSql.Append("GoodsSiteName=@GoodsSiteName,");
            strSql.Append("ProductBatchNum=@ProductBatchNum,");
            strSql.Append("InHouseTime=@InHouseTime,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("Remarks=@Remarks");
            strSql.Append(" where StockListID=@StockListID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ManaTaskID",       SqlDbType.BigInt,      8),
                new SqlParameter("@StoreHouseName",   SqlDbType.NVarChar,   20),
                new SqlParameter("@StockID",          SqlDbType.BigInt,      8),
                new SqlParameter("@ProductCode",      SqlDbType.NVarChar,   50),
                new SqlParameter("@ProductNum",       SqlDbType.Int,         4),
                new SqlParameter("@ProductStatus",    SqlDbType.NVarChar,   50),
                new SqlParameter("@ProductFrameCode", SqlDbType.NVarChar,   50),
                new SqlParameter("@ProductName",      SqlDbType.NVarChar,   20),
                new SqlParameter("@GoodsSiteName",    SqlDbType.NVarChar,   20),
                new SqlParameter("@ProductBatchNum",  SqlDbType.NVarChar,   50),
                new SqlParameter("@InHouseTime",      SqlDbType.DateTime),
                new SqlParameter("@UpdateTime",       SqlDbType.DateTime),
                new SqlParameter("@Remarks",          SqlDbType.NVarChar,  100),
                new SqlParameter("@StockListID",      SqlDbType.BigInt, 8)
            };
            parameters[0].Value  = model.ManaTaskID;
            parameters[1].Value  = model.StoreHouseName;
            parameters[2].Value  = model.StockID;
            parameters[3].Value  = model.ProductCode;
            parameters[4].Value  = model.ProductNum;
            parameters[5].Value  = model.ProductStatus;
            parameters[6].Value  = model.ProductFrameCode;
            parameters[7].Value  = model.ProductName;
            parameters[8].Value  = model.GoodsSiteName;
            parameters[9].Value  = model.ProductBatchNum;
            parameters[10].Value = model.InHouseTime;
            parameters[11].Value = model.UpdateTime;
            parameters[12].Value = model.Remarks;
            parameters[13].Value = model.StockListID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }