private void btnExportOrder_Click(object sender, EventArgs e) { StringBuilder output = new StringBuilder(); string headerLine = ColNameOnHand + "\t" + ColNameSubCategory + "\t" + ColNameBrand + "\t" + ColNameProduct + "\t" + ColNameSize + "\t" + ColNameModel + "\t" + ColNameVendorCode + "\t" + ColNameOrdered + "\t" + ColNameOrderEaches + "\t" + ColNameEachCost + "\t" + ColNameCaseCost + "\t" + ColNameCaseSize; output.AppendLine(headerLine); PersistedBindingList <JoinPlToVpToProd> data = mHelper.DataSource; foreach (JoinPlToVpToProd row in data) { string line = string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}", row.PurLine_QtyOnHand, row.SubCategoryName, row.BrandName, row.PurLine_ProductName, row.PurLine_Size, row.PurLine_ManufacturerPartNum, "#" + row.PurLine_VendorPartNum, row.PurLine_QtyOrdered, (row.PurLine_OrderedEaches ? "Y" : "N"), row.PurLine_EachCost.ToString("F2"), row.PurLine_CaseCost.ToString("F2"), row.PurLine_CountInCase); output.AppendLine(line); } System.Windows.Forms.Clipboard.SetText(output.ToString(), TextDataFormat.UnicodeText); MessageBox.Show("Order lines exported to clipboard in tab separated format."); MessageBox.Show(string.Format("Vendor codes have been prefixed with \"#\" to prevent " + "spreadsheets from interpreting them as numbers and stripping leading zeros. " + "Import will remove any leading \"#\" from vendor codes to undo this.", PurLineForm.ColNameVendorCode), "Vendor Codes", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
public void Show(VendorId vendorId, PurOrderId purOrderId, PersistedBindingList <JoinPlToVpToProd> purLines, List <ProductSubCategory> subCats, List <ProductBrand> brands) { mVendorId = vendorId; mOrderId = purOrderId; mPurLines = purLines; mPurLineDictionary = new Dictionary <string, JoinPlToVpToProd>(); foreach (JoinPlToVpToProd purLine in mPurLines) { if (!string.IsNullOrEmpty(purLine.PurLine_VendorPartNum)) { mPurLineDictionary.Add(purLine.PurLine_VendorPartNum, purLine); } } mSubCats = subCats; mBrands = brands; this.ShowDialog(); }