protected override void FillProps(System.Data.DataRow in_row) { base.FillProps(in_row); _modified = UnixEpoch.ToDateTime((long)in_row["modified"]); _matrixId = (int)(long)in_row["matrix_id"]; _priceOfPurchase = (int)(long)in_row["price_of_purchase"]; _priceOfSell = (int)(long)in_row["price_of_sell"]; }
protected override void FillProps(System.Data.DataRow in_row) { base.FillProps(in_row); _type = (DocType)(long)in_row["type"]; _timeCreated = UnixEpoch.ToDateTime((long)in_row["time_created"]); if ((in_row["time_cancelled"] as long?).HasValue) { _timeCancelled = UnixEpoch.ToDateTime((long)in_row["time_cancelled"]); } }
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); }
protected override void FillProps(System.Data.DataRow in_row) { base.FillProps(in_row); _doc = Doc.Restore(Id); _timeSold = UnixEpoch.ToDateTime((long)in_row["time_sold"]); _articleId = (int)(long)in_row["art_id"]; _articleName = (string)in_row["art_name"]; _articlePriceOfPurchase = (int)(long)in_row["art_price_of_purchase"]; _articlePriceOfSell = (int)(long)in_row["art_price_of_sell"]; _pointOfSaleId = (int)(long)in_row["point_of_sale_id"]; _pointOfSaleName = (string)in_row["point_of_sale_name"]; _unitPrice = (int)(long)in_row["unit_price"]; _unitCount = (int)(long)in_row["unit_count"]; _cellX = (string)in_row["cell_x"]; _cellY = (string)in_row["cell_y"]; _paymentByCard = (long)in_row["payment_by_card"] == 1; }
public static CellInStock Restore(string in_x, string in_y, SkuInStock in_skuInStock) { using SQLiteConnection conn = ConnectionRegistry.Instance.OpenNewConnection(); using SQLiteCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select *" + " from cell_in_stock" + " where point_of_sale_id = @in_pointOfSaleId" + " and article_id = @in_articleId" + " and x = @in_x" + " and y = @in_y"; cmd.Parameters.Add(new SQLiteParameter("@in_pointOfSaleId", in_skuInStock.PointOfSale.Id)); cmd.Parameters.Add(new SQLiteParameter("@in_articleId", in_skuInStock.Article.Id)); cmd.Parameters.Add(new SQLiteParameter("@in_x", in_x)); cmd.Parameters.Add(new SQLiteParameter("@in_y", in_y)); DataTable table = new DataTable(); using (SQLiteDataAdapter a = new SQLiteDataAdapter(cmd)) a.Fill(table); if (table.Rows.Count == 0) { return(null); } else if (table.Rows.Count == 1) { DataRow row = table.Rows[0]; return(CellInStock.Restore((int)(long)row["id"], UnixEpoch.ToDateTime((long)row["modified"]), in_skuInStock, in_x, in_y, (int)(long)row["amount"])); } else { throw new ApplicationException("CellInStock.Restore(string in_x, string in_y, SkuInStock in_skuInStock) returned more than 1 row."); } }