private void buttonOK_Click(object sender, EventArgs e) { ContractShipment c = new ContractShipment(); ObjectComboBox obj2 = (ObjectComboBox)comboBoxCells.SelectedItem; c.StoreCellFromId = obj2.Id; ObjectComboBox objPr = (ObjectComboBox)comboBoxProducts.SelectedItem; c.ProductId = objPr.Id; int amount = 0; Int32.TryParse(textBox1.Text, out amount); c.Amount = amount; c.Date = dateTimePicker1.Value.Date; if (Id == -1) { query.queryAddContractShipment(c); } else { c.Id = Id; query.queryUpdateContractShipment(c); } instance.refreshGrid(); this.Dispose(); }
public static void restore(ContractShipment co, int oldAmount) { ReportBalance rb = new ReportBalance(); rb.Amount = oldAmount - co.Amount; rb.Date = co.Date; rb.Id = new Random().Next(); rb.ProductId = co.ProductId; rb.StoreCellId = co.StoreCellFromId; new QueryReports().queryAddReportBalance(rb); }
private void addDataForUpdate() { ContractShipment c = query.queryFindContractShipmentById(Id); if (c == null) { return; } dateTimePicker1.Value = c.Date; comboBoxProducts.SelectedValue = c.ProductId; comboBoxStorehouses.SelectedValue = c.StoreCellFromObj.StorehouseId; addStorageCells((int)comboBoxStorehouses.SelectedValue, comboBoxCells); comboBoxCells.SelectedValue = c.StoreCellFromObj.Id; textBox1.Text = c.Amount + ""; }
public static List <ReportBalanceTable> querySelectReportBalanceByShip(ContractShipment co, int storeId) { using (DataBaseContext db = new DataBaseContext()) { var query = from c in db.ReportBalances join sc in db.StoreCells on c.StoreCellId equals sc.Id join sh in db.Storehouses on sc.StorehouseId equals sh.Id join p in db.Products on c.ProductId equals p.Id select new { c, p, sc, sh }; List <ReportBalanceTable> table = new List <ReportBalanceTable>(); foreach (var item in query) { if (co.ProductId == item.p.Id && co.StoreCellFromId == item.sc.Id && item.sh.Id == storeId) { table.Add(new ReportBalanceTable(item.c, item.p, item.sc, item.sh)); } } return(table); } }
protected override void Execute(CodeActivityContext context) { ContractShipment co = contr.Get(context); QueryContractShipment q = query.Get(context); int id = Id.Get(context); /*if (co.Amount < 0) * { * Result.Set(context, false); * return; * }*/ List <ReportBalanceTable> res = querySelectReportBalanceByShip(co, storeId.Get(context)); if (res == null || res.Count == 0) { if (oldAmount.Get(context) == 0 && mov.Get(context) != 1) { Result.Set(context, false); return; } else { Shipment.restore(co, oldAmount.Get(context)); if (mov.Get(context) != 1) { if (id == -1) { q.queryAddContractShipment(co); } else { co.Id = id; q.queryUpdateContractShipment(co); } } Result.Set(context, true); return; } } res[0].reportBalance.Amount -= (co.Amount - oldAmount.Get(context)); if (res[0].reportBalance.Amount < 0) { Result.Set(context, false); return; } if (mov.Get(context) != 1) { if (id == -1) { q.queryAddContractShipment(co); } else { co.Id = id; q.queryUpdateContractShipment(co); } } if (res[0].reportBalance.Amount > 0) { queryUpdateReportBalance(res[0].reportBalance); } else { new QueryReports().queryDeleteReportBalance(res[0].reportBalance.Id); } Result.Set(context, true); }