public string Format(TruckReturn ret) { return(string.Format( "TRUCK RETURN" + Environment.NewLine + "Date: {0}" + Environment.NewLine + "Salesman: {1}" + Environment.NewLine + "Route: {2}" + Environment.NewLine + "Reference No: {10}" + Environment.NewLine + "Customer: {8}" + Environment.NewLine + Environment.NewLine + "Code Description Unit Qty Price Disc Amount" + Environment.NewLine + "--------------------------------------------------------------------------------------" + Environment.NewLine + "{3}" + "--------------------------------------------------------------------------------------" + Environment.NewLine + " {7} {9} {6}" + Environment.NewLine + Environment.NewLine + "Prepared By: {4} Approved By: {5}", ret.Date.ToString(), ret.SalesRep.Name, ret.Route.Code, GetPrintableDetails(ret), ret.PreparedBy, ret.ApprovedBy, ret.TotalAmount.ToString("###,##0.00").PadLeft(9), ret.TotalQuantity.ToString("###,##0.00").PadLeft(8), ret.Customer.Name, ret.TotalDiscount.ToString("###,##0.00").PadLeft(8), ret.Id )); }
public void Print(TruckReturn ret) { if (printer != null && formatter != null) { printer.Print(formatter.Format(ret)); } }
void UndoToolStripMenuItemClick(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { foreach (ListViewItem li in listView1.SelectedItems) { TruckReturn t = returns[li.Index]; DeleteTruckReturn(t, null); } OnActivated(null); } }
void CloseToolStripMenuItemClick(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { using (AdminPasswordForm f = new AdminPasswordForm()) { if (WorkbenchSingleton.AddDialog(f) == DialogResult.OK) { foreach (ListViewItem li in listView1.SelectedItems) { TruckReturn t = returns[li.Index]; CloseTruckReturn(t, null); } OnActivated(null); } } } }
string GetPrintableDetails(TruckReturn ret) { string text = ""; foreach (TruckReturnItem i in SortItems(ret)) { text += string.Format( "{0} {1} {2} {3} {4} {6} {5}" + Environment.NewLine, i.Item.Name.Length < 12 ? i.Item.Name.PadRight(12) : (i.Item.Name.Substring(0, 9) + "...").PadRight(12), i.Item.SalesDescription.Length < 21 ? i.Item.SalesDescription.PadRight(21) : (i.Item.SalesDescription.Substring(0, 18) + "...").PadRight(21), i.Item.UnitMeasure.Length < 11 ? i.Item.UnitMeasure.PadRight(11) : (i.Item.UnitMeasure.Substring(0, 8) + "...").PadRight(11), i.Quantity.ToString("0.00").PadLeft(5), i.UnitPrice.ToString("0.00").PadLeft(8), i.Amount.ToString("0.00").PadLeft(9), i.Discount.ToString("0.00").PadLeft(8) ); } return(text); }
public void TestMethod() { TruckLoad load1 = new TruckLoad(); load1.Customer = new Customer(); load1.AddItem(new TruckLoadItem(new Item() { Name = "Item A", SalesPrice = 10 }, 1)); load1.AddItem(new TruckLoadItem(new Item() { Name = "Item B", SalesPrice = 10 }, 2)); TruckLoad load2 = new TruckLoad(); load2.Customer = new Customer(); load2.AddItem(new TruckLoadItem(new Item() { Name = "Item A", SalesPrice = 10 }, 1)); TruckReturn ret = new TruckReturn(); foreach (var l in new TruckLoad[] { load1, load2 }) { foreach (var i in l.Items) { Console.WriteLine(i.Quantity + " " + i.Item.Name + ", " + i.Amount); ret.AddItem(i); } } ret.Items[0].Quantity = 1; Console.WriteLine("Printing truck return..."); foreach (var i in ret.Items) { Console.WriteLine(i.Quantity + " " + i.Item.Name + ", " + i.Amount); } // ITruckReturnService service = new DummyTruckReturnService(); // service.SaveOrUpdate(ret); }
public TruckReturnForm(TruckReturn _return) { InitializeComponent(); this.TruckReturn = _return; listViewItems.Resize += delegate { columnHeader2.Width = listViewItems.Width - 22 - (columnHeader1.Width + columnHeader3.Width + columnHeader4.Width + columnHeader5.Width + columnHeader6.Width + columnHeader7.Width); }; newToolStripMenuItem.Click += delegate { if (ItemAdding != null) { ItemAdding(new TruckReturnItem(), null); } }; editToolStripMenuItem.Click += delegate { if (listViewItems.SelectedItems.Count > 0) { // TruckReturnItem i = ret.Items[listViewItems.SelectedItems[0].Index]; // using (TruckReturnItemForm f = new TruckReturnItemForm(i)) { // if (WorkbenchSingleton.AddDialog(f) == DialogResult.OK) { // ReturnItemsChanged(this, null); // } // } if (ItemChanging != null) { ItemChanging(ret.Items[listViewItems.SelectedItems[0].Index], null); } } }; deleteToolStripMenuItem.Click += delegate { if (listViewItems.SelectedItems.Count > 0) { ret.RemoveItem(ret.Items[listViewItems.SelectedItems[0].Index]); } }; buttonNew.Click += delegate { newToolStripMenuItem.PerformClick(); }; buttonEdit.Click += delegate { editToolStripMenuItem.PerformClick(); }; buttonDelete.Click += delegate { deleteToolStripMenuItem.PerformClick(); }; }
IList <TruckReturnItem> SortItems(TruckReturn ret) { IList <TruckReturnItem> nonEmpties = new List <TruckReturnItem>(); IList <TruckReturnItem> empties = new List <TruckReturnItem>(); foreach (TruckReturnItem i in ret.Items) { if (ItemUtility.IsEmpty(i.Item.Name)) { empties.Add(i); } else { nonEmpties.Add(i); } } IList <TruckReturnItem> items = new List <TruckReturnItem>(nonEmpties); foreach (TruckReturnItem i in empties) { items.Add(i); } return(items); }
// void ButtonAddClick(object sender, EventArgs e) // { // using (TruckReturnItemForm f = new TruckReturnItemForm()) { // f.Customer = (comboBoxCustomer.DataSource as IList<Customer>)[comboBoxCustomer.SelectedIndex]; // if (WorkbenchSingleton.AddDialog(f) == DialogResult.OK) { // ret.AddItem(f.Item); // // TruckReturnItem i = f.Item; // if (i.Item.IsFullCase()) { // using (TruckReturnItemForm returnItemForm = new TruckReturnItemForm()) { // returnItemForm.Customer = (comboBoxCustomer.DataSource as IList<Customer>)[comboBoxCustomer.SelectedIndex]; // string suggestedCode = ItemSuggestionUtility.Suggest(i.Item.Name.ToUpper().Replace("FC-", "MT-")); // returnItemForm.FindCode(suggestedCode, i.Quantity); // if (WorkbenchSingleton.AddDialog(returnItemForm) == DialogResult.OK) { // ret.AddItem(returnItemForm.Item); // } // } // } else if (i.Item.IsSMBFullCase()) { // using (TruckReturnItemForm returnItemForm = new TruckReturnItemForm()) { // returnItemForm.Customer = (comboBoxCustomer.DataSource as IList<Customer>)[comboBoxCustomer.SelectedIndex]; // string suggestedCode = ItemSuggestionUtility.Suggest(i.Item.Name.ToUpper().Replace("SMBFC-", "SMBMT-")); // returnItemForm.FindCode(suggestedCode, i.Quantity); // if (WorkbenchSingleton.AddDialog(returnItemForm) == DialogResult.OK) { // ret.AddItem(returnItemForm.Item); // } // } // } // } // } // } void ButtonClearClick(object sender, EventArgs e) { this.TruckReturn = new TruckReturn(); }
public EditTruckReturn(TruckReturn _return) { this._return = _return; }
public TruckReturnForm2(TruckReturn ret) { InitializeComponent(); this.TruckReturn = ret; listView1.Resize += delegate { columnHeader2.Width = listView1.Width - 22 - (columnHeader1.Width + columnHeader3.Width + columnHeader4.Width + columnHeader5.Width + columnHeader6.Width); }; }
public void Delete(TruckReturn t) { dao.Delete(t); }
public void SaveOrUpdate(TruckReturn t) { dao.SaveOrUpdate(t); }