public ActionResult Print(HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { var dto = DeliverySerializer.LoadFromStream(file.InputStream); return(View(dto)); } return(RedirectToAction("Index")); }
private void SetModel(string fileName) { var ofd = new OpenFileDialog() { FileName = fileName }; var dto = DeliverySerializer.LoadFromFile(ofd.FileName); SetModelToUI(dto); }
private void Open_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog() { }; var result = ofd.ShowDialog(this); if (result == DialogResult.OK) { var dto = DeliverySerializer.LoadFromFile(ofd.FileName); SetModelToUI(dto); } }
private void Save_Click(object sender, EventArgs e) { var sfd = new SaveFileDialog() { Filter = "Файлы заказов|*.dw" }; var result = sfd.ShowDialog(this); if (result == DialogResult.OK) { var dto = GetModelFromUI(); DeliverySerializer.WriteToFile(sfd.FileName, dto); } }
public ActionResult Print(HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { var dto = DeliverySerializer.LoadFromStream(file.InputStream); Dictionary <string, int> titleArray = new Dictionary <string, int>(); using (var db = new ApplicationDbContext()) { var row = new DbDeliveryRquest { ClientAddress = dto.ClientAddress, Filled = dto.Filled, TimeDeliver = dto.TimeDeliver, TotalCost = dto.TotalCost, FullName = dto.FullName }; row.WayPoints = new Collection <DbWayPoint>(); foreach (var wpDto in dto.WayPoints) { var wp = new DbWayPoint { Address = wpDto.Address, PlaceTitle = wpDto.PlaceTitle, ShopType = wpDto.ShopType, }; row.WayPoints.Add(wp); wp.ProductsList = new Collection <DbProduct>(); foreach (var product in wpDto.ProductsList) { var p = new DbProduct { Name = product.Name, Amount = product.Amount, Additions = product.Additions, Cost = product.Cost, }; wp.ProductsList.Add(p); } db.productList.AddRange(wp.ProductsList); } db.DeliveryRequest.Add(row); db.SaveChanges(); return(View(dto)); } } return(RedirectToAction("Index")); }
private void экспортЗаказаВWordToolStripMenuItem_Click(object sender, EventArgs e) { if (OrderControl.SelectedIndex == 0) { if (listBox1.SelectedIndex != -1) { var dto = DeliverySerializer.LoadFromFile(PathReturnFromListBox1()); CheckExistFile(DeliverySerializer.newPath, listbox1Id[listBox1.SelectedIndex]); WordExportOrders.WordExport(dto); } } else if (listBox2.SelectedIndex != -1) { var dto = DeliverySerializer.LoadFromFile(PathReturnFromListBox2()); CheckExistFile(DeliverySerializer.newPath, listbox1Id[listBox1.SelectedIndex]); WordExportOrders.WordExport(dto); } }
private void Save_Click(object sender, EventArgs e) { SqlConnection sqlcon = new SqlConnection(connection); if (dtbl.Rows.Count == 0 && type != "admin") { var sfd = new SaveFileDialog() { Filter = "Файлы заказов|*.dw", InitialDirectory = Application.StartupPath }; var result = sfd.ShowDialog(this); SqlCommand com = new SqlCommand("INSERT INTO Orders (Name,PlacesAmount,TotalPrice, State, Filepath, UserId) VALUES (@Name,@PlacesAmount,@TotalPrice,@State,@Filepath,@UserId)", sqlcon); com.Parameters.AddWithValue("Name", FullNameBox.Text); com.Parameters.AddWithValue("PlacesAmount", listBox1.Items.Count); com.Parameters.AddWithValue("TotalPrice", CostUD.Value); if (StateBox.SelectedItem == null) { StateBox.SelectedItem = "принят к обработке"; } com.Parameters.AddWithValue("State", StateBox.SelectedItem.ToString()); com.Parameters.AddWithValue("Filepath", sfd.FileName); com.Parameters.AddWithValue("UserId", id); sqlcon.Open(); com.ExecuteNonQuery(); if (result == DialogResult.OK) { var dto = GetModelFromUI(); DeliverySerializer.WriteToFile(sfd.FileName, dto); Close(); } } else { SqlCommand com = new SqlCommand("UPDATE Orders SET State = N'" + StateBox.SelectedItem.ToString() + "', Filepath = N'" + DeliverySerializer.newPath + "' WHERE Id = '" + orderId + "'", sqlcon); sqlcon.Open(); com.ExecuteNonQuery(); var dto = GetModelFromUI(); DeliverySerializer.WriteToFile(DeliverySerializer.newPath, dto); Close(); } }