private void F_RevAll_Click(object sender, EventArgs e) { // ProductWaybills = new List<ProductWaybillBM>(); /* ProductWaybillBM model = new ProductWaybillBM * { * ProductId = Convert.ToInt32(F_Name.SelectedValue) * }; * * ProductWaybills.Add(model);*/ List <ProductBM> list = _serviceM.Sort(Convert.ToInt32(F_Group.SelectedValue)); ProductWaybills.Clear(); foreach (ProductBM p in list) { ProductWaybills.Add(new ProductWaybillBM { ProductId = p.Id, Count = _serviceRV.CalcCount(p.Id) }); } if (ProductWaybills.Count == 0) { MessageBox.Show("Список продуктов пуст", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <ProductWaybillBM> ProductWaybillBM = new List <ProductWaybillBM>(); for (int i = 0; i < ProductWaybills.Count; ++i) { ProductWaybillBM.Add(new ProductWaybillBM { Id = ProductWaybills[i].Id, ProductId = ProductWaybills[i].ProductId, WaybillId = ProductWaybills[i].WaybillId, Count = ProductWaybills[i].Count }); } try { _serviceRV.CreateRevalGroup(new WaybillBM { Date = F_Date.Value, Summa = Convert.ToInt32(F_Summa.Text.Replace(".", ",")), Koef = Convert.ToDouble(F_Coeff.Text.Replace(".", ",")), ProductWaybills = ProductWaybillBM }, Convert.ToDouble(F_Coeff.Text.Replace(".", ","))); MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void F_Rev_Click(object sender, EventArgs e) { if (CheckForm()) { ProductWaybills = new List <ProductWaybillBM>(); ProductWaybillBM model = new ProductWaybillBM { ProductId = Convert.ToInt32(F_Name.SelectedValue), Count = _serviceRev.CalcCount(Convert.ToInt32(F_Name.SelectedValue)) }; ProductWaybills.Add(model); List <ProductWaybillBM> ProductWaybillBM = new List <ProductWaybillBM>(); for (int i = 0; i < ProductWaybills.Count; ++i) { ProductWaybillBM.Add(new ProductWaybillBM { Id = ProductWaybills[i].Id, ProductId = ProductWaybills[i].ProductId, WaybillId = ProductWaybills[i].WaybillId, Count = ProductWaybills[i].Count }); } try { _serviceRev.CreateReval(new WaybillBM { Date = F_Date.Value, Summa = Convert.ToInt32(F_Summa.Text), ProductWaybills = ProductWaybillBM }, Convert.ToDouble(F_Price.Text.Replace(",", "."))); MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }