示例#1
0
 public CellInStock this[string in_x, string in_y]
 {
     get
     {
         DressMatrix mtx = _article.Matrix;
         return(_cells[mtx.CellsX.IndexOf(in_x), mtx.CellsY.IndexOf(in_y)]);
     }
 }
示例#2
0
        public static SkuInStock Restore(Article in_article, PointOfSale in_pointOfSale)
        {
            SkuInStock skuInStock = new SkuInStock()
            {
                Article     = in_article,
                PointOfSale = in_pointOfSale
            };

            using SQLiteConnection conn = ConnectionRegistry.Instance.OpenNewConnection();
            using SQLiteCommand cmd     = conn.CreateCommand();

            cmd.CommandType = CommandType.Text;

            cmd.Parameters.Add(new SQLiteParameter("@in_articleId", in_article.Id));
            cmd.Parameters.Add(new SQLiteParameter("@in_pointOfSaleId", in_pointOfSale.Id));

            cmd.CommandText = "select *" +
                              " from cell_in_stock" +
                              " where point_of_sale_id = @in_pointOfSaleId" +
                              "   and article_id = @in_articleId";

            DataTable table = new DataTable();

            using (SQLiteDataAdapter a = new SQLiteDataAdapter(cmd))
                a.Fill(table);

            DressMatrix mtx = in_article.Matrix;

            CellInStock[,] cells = new CellInStock[mtx.CellsX.Count, mtx.CellsY.Count];

            foreach (DataRow row in table.Rows)
            {
                int x = mtx.CellsX.IndexOf((string)row["x"]);
                int y = mtx.CellsY.IndexOf((string)row["y"]);
                cells[x, y] = CellInStock.Restore((int)(long)row["id"], UnixEpoch.ToDateTime((long)row["modified"]), skuInStock, (string)row["x"], (string)row["y"], (int)(long)row["amount"]);
            }
            for (int x = 0; x < mtx.CellsX.Count; x++)
            {
                for (int y = 0; y < mtx.CellsY.Count; y++)
                {
                    if (cells[x, y] == null)
                    {
                        cells[x, y] = CellInStock.Restore(0, DateTime.Now, skuInStock, mtx.CellsX[x], mtx.CellsY[y], 0);
                    }
                }
            }

            skuInStock.SetCells(cells);

            return(skuInStock);
        }
示例#3
0
        public static SkuInStock CreateNew(Article in_article, PointOfSale in_pointOfSale)
        {
            SkuInStock result = new SkuInStock()
            {
                _article     = in_article,
                _pointOfSale = in_pointOfSale
            };
            DressMatrix mtx = in_article.Matrix;

            result._cells = new CellInStock[mtx.CellsX.Count, mtx.CellsY.Count];
            for (int x = 0; x < mtx.CellsX.Count; x++)
            {
                for (int y = 0; y < mtx.CellsY.Count; y++)
                {
                    result._cells[x, y] = CellInStock.Restore(0, DateTime.Now, result, mtx.CellsX[x], mtx.CellsY[y], 0);
                }
            }
            return(result);
        }