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); }
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); }
public static DocSale CreateNew(DateTime in_timeSold, Article in_article, PointOfSale in_pointOfSale, int in_unitPrice, int in_unitCount, CellInStock in_cell, bool in_paymentByCard) => new DocSale { _timeSold = in_timeSold, _articleId = in_article.Id, _articleName = in_article.Name, _articlePriceOfPurchase = in_article.PriceOfPurchase, _articlePriceOfSell = in_article.PriceOfSell, _pointOfSaleId = in_pointOfSale.Id, _pointOfSaleName = in_pointOfSale.Name, _unitPrice = in_unitPrice, _unitCount = in_unitCount, _cellX = in_cell.X, _cellY = in_cell.Y, _paymentByCard = in_paymentByCard };