private void ButAddDeliveryNote_Click(object sender, EventArgs e) { if (pData.Enabled == false) { pDeliveryNotes.Enabled = false; pData.Enabled = true; butAddDeliveryNote.BackColor = Color.Blue; butAddDeliveryNote.Text = "Отменить добавление"; lBDeliveryNotes.Enabled = false; lDeliveryNote.Text = "Новая накладная"; lDeliveryNote.Enabled = false; butSave.Enabled = true; deliveryNote = new DeliveryNoteDTO(); addedProducts = new List <ProductArrival>(); ReloadedData(); } else { pDeliveryNotes.Enabled = true; pData.Enabled = false; butAddDeliveryNote.BackColor = Color.LimeGreen; butAddDeliveryNote.Text = "Добавить новую накладную"; lBDeliveryNotes.Enabled = true; lDeliveryNote.Enabled = true; if ((lBDeliveryNotes.SelectedItem) != null) { lDeliveryNote.Text = (lBDeliveryNotes.SelectedItem).ToString(); } else { lDeliveryNote.Text = "Не выбрана"; } } }
public async Task <IActionResult> Create(DeliveryNoteDTO DeliveryNoteDTO) { var DeliveryNote = _mapper.Map <DeliveryNoteDTO, DeliveryNote>(DeliveryNoteDTO); await _unitOfWork.DeliveryNotes.Add(DeliveryNote); return(CreatedAtAction(nameof(GetBy), new { id = DeliveryNote.DeliveryNoteId }, DeliveryNote)); }
public void AddDeliveryNote(DeliveryNoteDTO model, string operatorId) { var order = _orderRepository.Get(model.OrderId); if (order == null) { throw new Exception("找不到指定的订单."); } var obj = DeliveryNoteFactory.CreateDeliveryNote(order, model.DeliveryNoteNo, model.Consignee, model.ConsigneeMobile, model.DeliveryAddress, model.ShippingMethod, model.CarrierName, model.CarrierPhone, model.ShippingAmount, operatorId); _deliveryNoteRepository.Add(obj); _dbUnitOfWork.Commit(); }
private void ButSave_Click(object sender, EventArgs e) { if (tBNumber.Text.Length != 0 && cBInvoices.SelectedItem != null && dGVProducts.Rows.Count != 0) { float Total = 0; foreach (var item in addedProducts) { Total += item.getSumRound(); AddProduct(item); } deliveryNote = new DeliveryNoteDTO { Number = int.Parse(tBNumber.Text), Date = dTPData.Value, InvoiceId = (cBInvoices.SelectedItem as InvoiceDTO).Id, PriemName = tBPriemName.Text, GruzName = tBGruzName.Text, FileName = MainForm.DB.Contracts.Get((cBInvoices.SelectedItem as InvoiceDTO).ContractId).ToString() + "\\Накладная №" + tBNumber.Text + " от " + dTPData.Value.ToLongDateString() + ".nakl" }; MainForm.DB.DeliveryNotes.Create(deliveryNote); MainForm.DB.Save(); string path = Application.StartupPath + "\\Local Data\\"; string subpath = MainForm.DB.Contracts.Get((cBInvoices.SelectedItem as InvoiceDTO).ContractId).ToString() + "\\"; DirectoryInfo dirInfo = new DirectoryInfo(path); if (!dirInfo.Exists) { dirInfo.Create(); } if (Directory.Exists(path)) { dirInfo.CreateSubdirectory(subpath); Stream stream = new FileStream(Application.StartupPath + "\\Local Data\\" + MainForm.DB.Contracts.Get((cBInvoices.SelectedItem as InvoiceDTO).ContractId).ToString() + "\\Накладная №" + tBNumber.Text + " от " + dTPData.Value.ToLongDateString() + ".nakl", FileMode.CreateNew); var serializer = new BinaryFormatter(); serializer.Serialize(stream, addedProducts); stream.Close(); } ReloadedDeliveryNotes(); MessageBox.Show("Накладная успешно сохранена и продукты добавлены на склад"); ButAddDeliveryNote_Click(this, new EventArgs()); } else { MessageBox.Show("Не все обязательные поля заполнены или список продуктов пуст!", "Ошибка сохранения накладной"); } }
public async Task <IHttpActionResult> GetDeliveryNote(int id) { DeliveryNote d = await db.DeliveryNotes.FindAsync(id); if (d == null) { return(NotFound()); } DeliveryNoteDTO deliveryNote = new DeliveryNoteDTO { id = d.id, date = d.date, driverId = d.driverId, orderId = d.orderId, status = d.status }; return(Ok(deliveryNote)); }
public static void Delete(int id) { DeliveryNoteDTO deliveryNote = MainForm.DB.DeliveryNotes.Get(id); if (MessageBox.Show("Вы уверены что хотите удалить накладную №" + deliveryNote.Number.ToString() + "?", "Удаление накладной", MessageBoxButtons.YesNo) == DialogResult.Yes) { InvoiceDTO invoice = MainForm.DB.Invoices.Get(deliveryNote.InvoiceId); Stream stream = new FileStream(Application.StartupPath + "\\Local Data\\" + invoice.FileName, FileMode.Open); List <ProductArrival> productsInInvoice = new BinaryFormatter().Deserialize(stream) as List <ProductArrival>; stream.Close(); stream = new FileStream(Application.StartupPath + "\\Local Data\\" + deliveryNote.FileName, FileMode.Open); List <ProductArrival> productsInDeliveryNote = new BinaryFormatter().Deserialize(stream) as List <ProductArrival>; stream.Close(); foreach (ProductArrival productInDeliveryNote in productsInDeliveryNote) { for (int i = 0; i < productsInInvoice.Count; i++) { if (productsInInvoice[i].Id == productInDeliveryNote.Id) { productsInInvoice[i].Balance = (float)(productsInInvoice[i].Balance + productInDeliveryNote.Balance); } } } string path = Application.StartupPath + "\\Local Data\\" + deliveryNote.FileName; File.Delete(path); stream = new FileStream(Application.StartupPath + "\\Local Data\\" + invoice.FileName, FileMode.Create); var serializer = new BinaryFormatter(); serializer.Serialize(stream, productsInInvoice); stream.Close(); MainForm.DB.DeliveryNotes.Delete(deliveryNote.Id); MainForm.DB.Save(); } }
public async Task <IActionResult> Update(int id, DeliveryNoteDTO DeliveryNoteDTO) { if (DeliveryNoteDTO.DeliveryNoteId != id) { return(BadRequest()); } try { var DeliveryNote = _mapper.Map <DeliveryNoteDTO, DeliveryNote>(DeliveryNoteDTO); await _unitOfWork.DeliveryNotes.Update(id, DeliveryNote); } catch (DbUpdateConcurrencyException) { if (!await DeliveryNoteExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Post([FromBody] DeliveryNoteDTO model) { _deliveryNoteAppService.AddDeliveryNote(model, UserId); }