private void thk_TextChanged(object sender, EventArgs e) { parent.textBoxTextChanged2(sender, e); if (dia.Text.Length > 0 && thk.Text.Length > 0) { Ref_BaseCharge = getDiaThk(Convert.ToDouble(dia.Text), Convert.ToDouble(thk.Text)) ?? new baseCharges(); Calculate_Die_Price(true); } }
// Return the next biggest public baseCharges getDiaThk(double refDia, double refThk, DieType dt, bool isOddDimensions = true) { if (refDia * refThk == 0) // If either dimensions are based 0, call for quote { return(null); } baseCharges Ref_Base = parent.baseCharge_List.FirstOrDefault(x => x.Diameter * (isOddDimensions ? 1 : MetricFactor) >= refDia - (parent.isMetric ? parent.metricTolerance : 0) && x.Thickness * (isOddDimensions ? 1 : MetricFactor) >= refThk - (parent.isMetric ? parent.metricTolerance : 0) && x.Prefix == parent.Get_Die_Prefix(dt)); return(Ref_Base); }
// Return the next biggest public baseCharges getDiaThk(double refDia, double refThk) { baseCharges Ref_Base = parent.baseCharge_List.FirstOrDefault(x => x.Diameter * MetricFactor >= refDia - (parent.isMetric ? parent.metricTolerance : 0) && x.Thickness * MetricFactor >= refThk - (parent.isMetric ? parent.metricTolerance : 0) && x.Prefix == "HO"); if (Ref_Base != null) { showOdds.Text = "(Odd Diameter: " + Ref_Base.Diameter + " inches)"; showOddThk.Text = "(Odd Thickness: " + Ref_Base.Thickness + " inches)"; } return(Ref_Base); }
// Return the next biggest with inner dia (for rings) public baseCharges getDiaThk(double refDia, double refThk, double innerDia, DieType dt, bool isOddDimensions = true) { if (parent.baseCharge_List.Where(x => x.Prefix == parent.Get_Die_Prefix(dt)).Count() == 0) { baseCharges BC = new baseCharges() { Diameter = refDia, Thickness = refThk, InnerDiameter = innerDia, }; BC.Price = BC.Get_Ring_Price(); return(BC); } baseCharges Ref_Base = parent.baseCharge_List.FirstOrDefault(x => x.Diameter * (isOddDimensions ? 1 : MetricFactor) >= refDia - (parent.isMetric ? parent.metricTolerance : 0) && x.InnerDiameter * (isOddDimensions ? 1 : MetricFactor) >= innerDia && x.Thickness * (isOddDimensions ? 1 : MetricFactor) >= refThk - (parent.isMetric ? parent.metricTolerance : 0) && x.Prefix == parent.Get_Die_Prefix(dt)); return(Ref_Base); }
private void addChargesButton_Click(object sender, EventArgs e) { if (Ref_BaseCharge != null) { if (dia.Text.Length > 0 && thk.Text.Length > 0) { Ref_BaseCharge = getDiaThk(Convert.ToDouble(dia.Text), Convert.ToDouble(thk.Text)) ?? new baseCharges(); } Grey_Out(); using (var form = new Extra_Charges(parent, DieCharge_List, dt, Ref_BaseCharge.Price + current_cav_price, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK) { DieCharge_List = form.Ref_List; } } Calculate_Die_Price(true); Grey_In(); } }
// Return the next biggest public baseCharges getDiaThk(double refDia, double refThk, double innerDia) { if (parent.baseCharge_List.Where(x => x.Prefix == parent.Get_Die_Prefix(dt)).Count() == 0) { baseCharges BC = new baseCharges() { Diameter = refDia / (parent.isMetric ? 25.4 : 1), Thickness = refThk / (parent.isMetric ? 25.4 : 1), InnerDiameter = innerDia / (parent.isMetric ? 25.4 : 1), }; BC.Price = BC.Get_Ring_Price(); return(BC); } baseCharges Ref_Base = parent.baseCharge_List.FirstOrDefault(x => x.Diameter * MetricFactor >= refDia - (parent.isMetric ? parent.metricTolerance : 0) && x.InnerDiameter * MetricFactor >= innerDia && x.Thickness * MetricFactor >= refThk - (parent.isMetric ? parent.metricTolerance : 0) && x.Prefix == parent.Get_Die_Prefix(dt)); if (Ref_Base != null) { showOdds.Text = "(Odd Diameter: " + Ref_Base.Diameter + " inches)"; showOddThk.Text = "(Odd Thickness: " + Ref_Base.Thickness + " inches)"; } return(Ref_Base); }
public PDFGenerator(Main parent_, string OrderID, bool GenerateFromHistory = true, string print_name = "") { parent = parent_; if (parent.isMetric) { MetricFactor = 25.4; } int data_height = 15; Ref_Order = parent.Order_List.FirstOrDefault(x => x.ID == OrderID); if (Ref_Order == null) { Ref_Order = new Order() { PO = parent.PO, Authorizer = parent.Auth, Requisitioner = parent.Req, Due = parent.Due, DieQty = parent.Solid_List.Count + parent.Hollow_List.Count + parent.Support_List.Count, Date = DateTime.Now, ID = parent.randomID, FreightCost = parent.currentFreightCost, Total = parent.Current_Order_Total }; } string fileName = "EXCO_Purchase_Order" + " (QTY-" + Ref_Order.DieQty + " @ " + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second + DateTime.Now.Millisecond + ")"; if (print_name.Length > 0) { fileName = print_name; } document.Info.Author = "EXCO"; document.Info.Subject = "Quote-Generating Program"; document.Info.Title = "Exco Pricing Tool Order"; page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("MS Reference Sans Serif", 10, XFontStyle.Bold); XFont fontreg = new XFont("MS Reference Sans Serif", 10, XFontStyle.Regular); XFont smallfont = new XFont("MS Reference Sans Serif", 7, XFontStyle.Bold); XFont smallfontreg = new XFont("MS Reference Sans Serif", 7, XFontStyle.Regular); XFont bigfontbold = new XFont("MS Reference Sans Serif", 25, XFontStyle.Bold); XTextFormatter tf = new XTextFormatter(gfx); DrawHeader(gfx, page); List <Solid> Solid_List = !GenerateFromHistory ? parent.Solid_List : parent.Solid_List_History; List <Hollow> Hollow_List = !GenerateFromHistory ? parent.Hollow_List : parent.Hollow_List_History; List <Support> Support_List = !GenerateFromHistory ? parent.Support_List : parent.Support_List_History; double surcharge_total = 0; //unit of measure string unit = parent.isMetric ? " mm" : " in"; #region Solid foreach (Solid s in Solid_List.Where(x => x.OrderID == OrderID).ToList()) { baseCharges Ref_Base = getDiaThk(s.OddDiameter, s.OddThickness, s.DieType); // If returns null, invalid dimensions needsCallQuote = Ref_Base == null; if (needsCallQuote) { needsCallQuote2 = true; } // Get surcharge price double weight = 0; if (!needsCallQuote) { GetSurchargeWeight(0, s.DieType, Ref_Base.Diameter, Ref_Base.Thickness, 1, ref weight); } surcharge_total += s.SurchargePrice; DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), s.DieType + " Die (" + Math.Round(s.Diameter * (parent.isMetric ? 25.4 : 1), 2) + unit + " X " + Math.Round(s.Thickness * (parent.isMetric ? 25.4 : 1), 2) + unit + ") - " + s.HoleCount + " Cavit" + (s.HoleCount > 1 ? "ies" : "y"), needsCallQuote ? CFQ : (Ref_Base.Price + s.CavityPrice).ToString(), needsCallQuote ? CFQ : (s.BasePrice).ToString(), false, !needsCallQuote); DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Part #: " + s.DieNo.Replace("--", "-"), "", "", true, false); if (s.Location.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Location: " + s.Location, "", "", true, false); } if (s.Nitride) { double nitrideprice = parent.GetFreightWeight("", s.DieType, s.Diameter, s.Thickness, 0) * parent.nitrideRate; DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Nitriding", needsCallQuote ? CFQ : nitrideprice.ToString(), "", true, !needsCallQuote); } if (s.Pocket) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Pocketing", needsCallQuote ? CFQ : "50", "", true, !needsCallQuote); } if (s.FE_Backer_No.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "For existing Backer #: " + s.FE_Backer_No + " at location: " + s.FE_Backer_Loc, "", "", true, false); } if (s.FE_Feeder_No.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "For existing Feeder #:" + s.FE_Feeder_No + " at location: " + s.FE_Feeder_Loc, "", "", true, false); } if (s.FE_Bolster_No.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "For existing Bolster #:" + s.FE_Bolster_No + " at location: " + s.FE_Bolster_Loc, "", "", true, false); } if (s.FE_SubBol_Loc.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "For existing Sub Bolster #:" + s.FE_SubBol_No + " at location: " + s.FE_SubBol_Loc, "", "", true, false); } if (s.Notes.Length > 0) { List <string> note_line = s.Notes.Split(new string[] { "```" }, StringSplitOptions.None).ToList(); DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Notes: " + note_line[0], "", "", true, false); height_offset -= 2; foreach (string line in note_line.GetRange(1, note_line.Count - 1)) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), " " + line, "", "", true, false); height_offset -= 2; } } foreach (DieCharge DC in s.Charge_List) { if (DC.Quantity > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), DC.Name + " (" + DC.Quantity + ")" + (DC.Notes.Length > 0 ? ": " + DC.Notes : ""), needsCallQuote ? CFQ : (DC.Quantity * DC.GetAdditionalCost(Ref_Base.Price + s.CavityPrice)).ToString(), "", true, !needsCallQuote); } } DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Steel Surcharge", needsCallQuote ? CFQ : (s.SurchargePrice).ToString(), "", true, !needsCallQuote); if (ifNewPage(start_height + height_offset + (row_count++ *data_height))) { row_count = 0; height_offset = 0; NextPage(ref gfx, document); } } #endregion #region Hollow foreach (Hollow s in Hollow_List.Where(x => x.OrderID == OrderID).ToList()) { if (s.Plate_Only || s.Mandrel_Only || s.No_Backer) { needsCallQuote = true; needsCallQuote2 = true; } baseCharges Ref_Base = getDiaThk(s.OddDiameter, s.OddThickness, s.DieType); // If returns null, invalid dimensions needsCallQuote = Ref_Base == null; if (needsCallQuote) { needsCallQuote2 = true; } // Get surcharge price double weight = 0; if (!needsCallQuote) { GetSurchargeWeight(0, s.DieType, Ref_Base.Diameter, Ref_Base.Thickness, 1, ref weight); } surcharge_total += s.SurchargePrice; DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), s.DieType + " Die (" + Math.Round(s.Diameter * (parent.isMetric ? 25.4 : 1), 2) + unit + " X " + Math.Round(s.Thickness * (parent.isMetric ? 25.4 : 1), 2) + unit + ") - " + s.HoleCount + " Cavit" + (s.HoleCount > 1 ? "ies" : "y"), needsCallQuote ? CFQ : (Ref_Base.Price + s.CavityPrice).ToString(), needsCallQuote ? CFQ : (s.BasePrice).ToString(), false, !needsCallQuote); DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Part #: " + s.DieNo.Replace("--", "-"), "", "", true, false); if (s.Location.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Location: " + s.Location, "", "", true, false); } if (s.Plate_Only || s.Mandrel_Only || s.No_Backer) { string str = s.Plate_Only ? "Plate Only" : (s.Mandrel_Only ? "Mandrel Only" : "No Backer"); DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), str, needsCallQuote ? CFQ : "50", "", true, !needsCallQuote); } if (s.Nitride) { double nitrideprice = parent.GetFreightWeight("", s.DieType, s.Diameter, s.Thickness, 0) * parent.nitrideRate; DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Nitriding", needsCallQuote ? CFQ : nitrideprice.ToString(), "", true, !needsCallQuote); } if (s.FE_Backer_No.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "For existing Backer #: " + s.FE_Backer_No + " at location: " + s.FE_Backer_Loc, "", "", true, false); } if (s.FE_Feeder_No.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "For existing Feeder #:" + s.FE_Feeder_No + " at location: " + s.FE_Feeder_Loc, "", "", true, false); } if (s.FE_Bolster_No.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "For existing Bolster #:" + s.FE_Bolster_No + " at location: " + s.FE_Bolster_Loc, "", "", true, false); } if (s.FE_SubBol_Loc.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "For existing Sub Bolster #:" + s.FE_SubBol_No + " at location: " + s.FE_SubBol_Loc, "", "", true, false); } if (s.Notes.Length > 0) { List <string> note_line = s.Notes.Split(new string[] { "```" }, StringSplitOptions.None).ToList(); DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Notes: " + note_line[0], "", "", true, false); height_offset -= 2; foreach (string line in note_line.GetRange(1, note_line.Count - 1)) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), " " + line, "", "", true, false); height_offset -= 2; } } foreach (DieCharge DC in s.Charge_List) { if (DC.Quantity > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), DC.Name + " (" + DC.Quantity + ")" + (DC.Notes.Length > 0 ? ": " + DC.Notes : ""), needsCallQuote ? CFQ : (DC.Quantity * DC.GetAdditionalCost(Ref_Base.Price + s.CavityPrice)).ToString(), "", true, !needsCallQuote); } } DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Steel Surcharge", needsCallQuote ? CFQ : (s.SurchargePrice).ToString(), "", true, !needsCallQuote); if (ifNewPage(start_height + height_offset + (row_count++ *data_height))) { row_count = 0; height_offset = 0; NextPage(ref gfx, document); } } #endregion #region Support foreach (Support s in Support_List.Where(x => x.OrderID == OrderID).ToList()) { baseCharges Ref_Base; if (s.DieType == DieType.Ring) { Ref_Base = getDiaThk(s.OddDiameter, s.OddThickness, s.InnerDiameter, s.DieType); } else { Ref_Base = getDiaThk(s.OddDiameter, s.OddThickness, s.DieType); } // If returns null, invalid dimensions needsCallQuote = Ref_Base == null; if (needsCallQuote) { needsCallQuote2 = true; } // Get surcharge price double weight = 0; if (!needsCallQuote) { GetSurchargeWeight(0, s.DieType, Ref_Base.Diameter, Ref_Base.Thickness, 1, ref weight); } surcharge_total += s.SurchargePrice; DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), s.DieType + " Die (" + Math.Round(s.Diameter * (parent.isMetric ? 25.4 : 1), 2) + unit + " X " + Math.Round(s.Thickness * (parent.isMetric ? 25.4 : 1), 2) + unit + ") - " + s.HoleCount + " Cavit" + (s.HoleCount > 1 ? "ies" : "y"), needsCallQuote ? CFQ : (Ref_Base.Price + s.CavityPrice).ToString(), needsCallQuote ? CFQ : (s.BasePrice).ToString(), false, !needsCallQuote); if (s.InnerDiameter > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Ring Inner Diameter: " + Math.Round(s.InnerDiameter * (parent.isMetric ? 25.4 : 1), 2) + unit, "", "", true, false); } DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Part #: " + s.DieNo.Replace("--", "-"), "", "", true, false); if (s.Location.Length > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Location: " + s.Location, "", "", true, false); } if (s.Notes.Length > 0) { List <string> note_line = s.Notes.Split(new string[] { "```" }, StringSplitOptions.None).ToList(); DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Notes: " + note_line[0], "", "", true, false); height_offset -= 2; foreach (string line in note_line.GetRange(1, note_line.Count - 1)) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), " " + line, "", "", true, false); height_offset -= 2; } } foreach (DieCharge DC in s.Charge_List) { if (DC.Quantity > 0) { DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), DC.Name + " (" + DC.Quantity + ")" + (DC.Notes.Length > 0 ? ": " + DC.Notes : ""), needsCallQuote ? CFQ : (DC.Quantity * DC.GetAdditionalCost(Ref_Base.Price + s.CavityPrice)).ToString(), "", true, !needsCallQuote); } } DrawRow(ref gfx, page, start_height + height_offset + (row_count++ *data_height), "Steel Surcharge", needsCallQuote ? CFQ : (s.SurchargePrice).ToString(), "", true, !needsCallQuote); if (ifNewPage(start_height + height_offset + (row_count++ *data_height))) { row_count = 0; height_offset = 0; NextPage(ref gfx, document); } } #endregion #region Summation line row_count++; DrawTotal(ref gfx, page, start_height + height_offset + (row_count++ *data_height), Ref_Order, surcharge_total); #endregion document.Save(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), fileName + ".pdf")); // Open only if not printing if (print_name.Length == 0) { Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), fileName + ".pdf")); } }
// Panel paint private void panel1_Paint(object sender, PaintEventArgs e) { //unit of measure string unit = parent.isMetric ? " mm" : " in"; // allow scroll transformation e.Graphics.TranslateTransform(bufferedPanel3.AutoScrollPosition.X, bufferedPanel3.AutoScrollPosition.Y); var panel = bufferedPanel3; int data_height = 16; int row_count = 0; int height_offset = 1; int start_height = 0; int start_margin = 15; // Item int item_charge_col = itemchg.Left + 5; int extn_price_col = extn.Left; int main_margin = start_margin + 25; Color DrawForeColor = Color.White; Color BackColor = Color.FromArgb(64, 64, 64); Color HighlightColor = Color.FromArgb(76, 76, 76); SolidBrush WritingBrush = new SolidBrush(DrawForeColor); SolidBrush GreyBrush = new SolidBrush(Color.FromArgb(88, 88, 88)); SolidBrush RedBrush = new SolidBrush(Color.FromArgb(150, 150, 150)); SolidBrush GreenBrush = new SolidBrush(Color.LightGreen); Pen p = new Pen(WritingBrush, 1); Pen Grey_Pen = new Pen(GreyBrush, 1); Font f_minor = new Font("MS Reference Sans Serif", 8.5F, FontStyle.Regular); Font f = new Font("MS Reference Sans Serif", 9.5F, FontStyle.Regular); Font f_strike = new Font("MS Reference Sans Serif", 9, FontStyle.Strikeout); Font f_total = new Font("MS Reference Sans Serif", 8, FontStyle.Bold); Font f_header = new Font("MS Reference Sans Serif", 10, FontStyle.Underline); Font f_italic = new Font("MS Reference Sans Serif", 9, FontStyle.Italic); Font f_9_bold = new Font("MS Reference Sans Serif", 9, FontStyle.Bold); Font f_10_bold = new Font("MS Reference Sans Serif", 10, FontStyle.Bold); Font f_10 = new Font("MS Reference Sans Serif", 10, FontStyle.Regular); Font f_9 = new Font("MS Reference Sans Serif", 9, FontStyle.Regular); Font f_14_bold = new Font("MS Reference Sans Serif", 14, FontStyle.Bold); Font f_12_bold = new Font("MS Reference Sans Serif", 11, FontStyle.Bold); double surcharge_total = 0; List <Solid> Solid_List = externalID.Length > 0 ? parent.Solid_List_History.Where(x => x.OrderID == externalID).ToList() : parent.Solid_List; List <Hollow> Hollow_List = externalID.Length > 0 ? parent.Hollow_List_History.Where(x => x.OrderID == externalID).ToList() : parent.Hollow_List; List <Support> Support_List = externalID.Length > 0 ? parent.Support_List_History.Where(x => x.OrderID == externalID).ToList() : parent.Support_List; if (externalID.Length > 0) { Ref_Order = parent.Order_List.First(x => x.ID == externalID); } #region Solid Dies foreach (Solid s in Solid_List) { baseCharges Ref_Base = getDiaThk(s.OddDiameter, s.OddThickness, s.DieType, true); // If returns null, invalid dimensions needsCallQuote = Ref_Base == null; if (needsCallQuote) { needsCallQuote2 = true; } // Get surcharge price double weight = 0; if (!needsCallQuote) { GetSurchargeWeight(0, s.DieType, Ref_Base.Diameter, Ref_Base.Thickness, 1, out weight); } surcharge_total += s.SurchargePrice; e.Graphics.DrawString(s.DieType + " Die (" + Math.Round(s.Diameter * (parent.isMetric ? 25.4 : 1), 2) + unit + " X " + Math.Round(s.Thickness * (parent.isMetric ? 25.4 : 1), 2) + unit + ") - " + s.HoleCount + " Cavit" + (s.HoleCount > 1 ? "ies" : "y"), f, WritingBrush, start_margin, start_height + height_offset + (row_count * data_height)); // Base price e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", Ref_Base.Price + s.CavityPrice), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); // Extension price e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", s.BasePrice), f_minor, WritingBrush, extn_price_col, start_height + height_offset + (row_count * data_height)); row_count++; //height_offset += 5; e.Graphics.DrawString("Part #: " + s.DieNo.Replace("--", "-"), f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; if (s.Location.Length > 0) { e.Graphics.DrawString("Location: " + s.Location, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.Nitride) { double nitrideprice = 0; // Nitride cost if (!needsCallQuote) { nitrideprice = parent.GetFreightWeight("", s.DieType, s.Diameter, s.Thickness, 0) * parent.nitrideRate; } e.Graphics.DrawString("Nitriding", f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", nitrideprice), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.Pocket) { // Nitride cost e.Graphics.DrawString("Pocketing", f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString("$" + String.Format("{0:0.00}", 50), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.FE_Backer_No.Length > 0) { e.Graphics.DrawString("For existing Backer #: " + s.FE_Backer_No + " at location: " + s.FE_Backer_Loc, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.FE_Feeder_No.Length > 0) { e.Graphics.DrawString("For existing Feeder #:" + s.FE_Feeder_No + " at location: " + s.FE_Feeder_Loc, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.FE_Bolster_No.Length > 0) { e.Graphics.DrawString("For existing Bolster #:" + s.FE_Bolster_No + " at location: " + s.FE_Bolster_Loc, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.FE_SubBol_Loc.Length > 0) { e.Graphics.DrawString("For existing Sub Bolster #:" + s.FE_SubBol_No + " at location: " + s.FE_SubBol_Loc, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.Notes.Length > 0) { List <string> note_line = s.Notes.Split(new string[] { "```" }, StringSplitOptions.None).ToList(); e.Graphics.DrawString("Notes: " + note_line[0], f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; foreach (string line in note_line.GetRange(1, note_line.Count - 1)) { e.Graphics.DrawString(" " + line, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } } foreach (DieCharge DC in s.Charge_List) { if (DC.Quantity > 0) { e.Graphics.DrawString(DC.Name + " (" + DC.Quantity + ")" + (DC.Notes.Length > 0 ? ": " + DC.Notes : ""), f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", DC.Quantity * DC.GetAdditionalCost(Ref_Base.Price + s.CavityPrice)), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); row_count++; } } e.Graphics.DrawString("Steel Surcharge", f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", s.SurchargePrice), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); row_count += 3; } #endregion #region Hollow Dies foreach (Hollow s in Hollow_List) { if (s.Plate_Only || s.Mandrel_Only || s.No_Backer) { needsCallQuote = true; needsCallQuote2 = true; } baseCharges Ref_Base = getDiaThk(s.OddDiameter, s.OddThickness, s.DieType, true); // If returns null, invalid dimensions needsCallQuote = Ref_Base == null; if (needsCallQuote) { needsCallQuote2 = true; } // Get surcharge price double weight = 0; if (!needsCallQuote) { GetSurchargeWeight(0, s.DieType, Ref_Base.Diameter, Ref_Base.Thickness, 1, out weight); } surcharge_total += s.SurchargePrice; e.Graphics.DrawString(s.DieType + " Die (" + Math.Round(s.Diameter * (parent.isMetric ? 25.4 : 1), 2) + unit + " X " + Math.Round(s.Thickness * (parent.isMetric ? 25.4 : 1), 2) + unit + ") - " + s.HoleCount + " Cavit" + (s.HoleCount > 1 ? "ies" : "y"), f, WritingBrush, start_margin, start_height + height_offset + (row_count * data_height)); // Base price e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", Ref_Base.Price + s.CavityPrice), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); // Extension price e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", s.BasePrice), f_minor, WritingBrush, extn_price_col, start_height + height_offset + (row_count * data_height)); row_count++; //height_offset += 5; e.Graphics.DrawString("Part #: " + s.DieNo.Replace("--", "-"), f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; if (s.Location.Length > 0) { e.Graphics.DrawString("Location: " + s.Location, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.Nitride) { double nitrideprice = 0; // Ni tride cost if (!needsCallQuote) { nitrideprice = parent.GetFreightWeight("", s.DieType, s.Diameter, s.Thickness, 0) * parent.nitrideRate; } e.Graphics.DrawString("Nitriding", f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", nitrideprice), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.FE_Backer_No.Length > 0) { e.Graphics.DrawString("For existing Backer #: " + s.FE_Backer_No + " at location: " + s.FE_Backer_Loc, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.FE_Feeder_No.Length > 0) { e.Graphics.DrawString("For existing Feeder #:" + s.FE_Feeder_No + " at location: " + s.FE_Feeder_Loc, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.FE_Bolster_No.Length > 0) { e.Graphics.DrawString("For existing Bolster #:" + s.FE_Bolster_No + " at location: " + s.FE_Bolster_Loc, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.FE_SubBol_Loc.Length > 0) { e.Graphics.DrawString("For existing Sub Bolster #:" + s.FE_SubBol_No + " at location: " + s.FE_SubBol_Loc, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.Notes.Length > 0) { List <string> note_line = s.Notes.Split(new string[] { "```" }, StringSplitOptions.None).ToList(); e.Graphics.DrawString("Notes: " + note_line[0], f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; foreach (string line in note_line.GetRange(1, note_line.Count - 1)) { e.Graphics.DrawString(" " + line, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } } foreach (DieCharge DC in s.Charge_List) { if (DC.Quantity > 0) { e.Graphics.DrawString(DC.Name + " (" + DC.Quantity + ")" + (DC.Notes.Length > 0 ? ": " + DC.Notes : ""), f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", DC.Quantity * DC.GetAdditionalCost(Ref_Base.Price + s.CavityPrice)), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); row_count++; } } e.Graphics.DrawString("Steel Surcharge", f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", s.SurchargePrice), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); row_count += 3; } #endregion #region Support Dies foreach (Support s in Support_List) { baseCharges Ref_Base; if (s.DieType == DieType.Ring) { Ref_Base = getDiaThk(s.OddDiameter, s.OddThickness, s.InnerDiameter, s.DieType, true); } else { Ref_Base = getDiaThk(s.OddDiameter, s.OddThickness, s.DieType, true); } // If returns null, invalid dimensions needsCallQuote = Ref_Base == null; if (needsCallQuote) { needsCallQuote2 = true; } // Get surcharge price double weight = 0; if (!needsCallQuote) { GetSurchargeWeight(0, s.DieType, Ref_Base.Diameter, Ref_Base.Thickness, 1, out weight); } surcharge_total += s.SurchargePrice; e.Graphics.DrawString(s.DieType + " (" + Math.Round(s.Diameter * (parent.isMetric ? 25.4 : 1), 2) + unit + " X " + Math.Round(s.Thickness * (parent.isMetric ? 25.4 : 1), 2) + unit + ") - " + s.HoleCount + " Cavit" + (s.HoleCount > 1 ? "ies" : "y"), f, WritingBrush, start_margin, start_height + height_offset + (row_count * data_height)); // Base price e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", Ref_Base.Price + s.CavityPrice), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); // Extension price e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", s.BasePrice), f_minor, WritingBrush, extn_price_col, start_height + height_offset + (row_count * data_height)); row_count++; if (s.InnerDiameter > 0) { e.Graphics.DrawString("Ring Inner Diameter: " + Math.Round(s.InnerDiameter * (parent.isMetric ? 25.4 : 1), 2) + unit, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } //height_offset += 5; e.Graphics.DrawString("Part #: " + s.DieNo.Replace("--", "-"), f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; if (s.Location.Length > 0) { e.Graphics.DrawString("Location: " + s.Location, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } if (s.Notes.Length > 0) { List <string> note_line = s.Notes.Split(new string[] { "```" }, StringSplitOptions.None).ToList(); e.Graphics.DrawString("Notes: " + note_line[0], f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; foreach (string line in note_line.GetRange(1, note_line.Count - 1)) { e.Graphics.DrawString(" " + line, f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); row_count++; } } foreach (DieCharge DC in s.Charge_List) { if (DC.Quantity > 0) { e.Graphics.DrawString(DC.Name + " (" + DC.Quantity + ")" + (DC.Notes.Length > 0 ? ": " + DC.Notes : ""), f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", DC.Quantity * DC.GetAdditionalCost(Ref_Base.Price)), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); row_count++; } } e.Graphics.DrawString("Steel Surcharge", f_minor, WritingBrush, main_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", s.SurchargePrice), f_minor, WritingBrush, item_charge_col, start_height + height_offset + (row_count * data_height)); row_count += 3; } #endregion height_offset -= 3; // Draw sub lines header line e.Graphics.DrawLine(p, itemchg.Left, start_height + height_offset + (row_count * data_height), itemchg.Right, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawLine(p, extn.Left, start_height + height_offset + (row_count * data_height), extn.Right, start_height + height_offset + (row_count * data_height)); // Subtotal height_offset += 3; e.Graphics.DrawString("Subtotal (including steel surcharge)", f, WritingBrush, start_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote2 ? CFQ : "$" + String.Format("{0:0.00}", (Ref_Order != null ? (Ref_Order.Total - Ref_Order.FreightCost) : parent.Current_Order_Total - parent.currentFreightCost)), f_minor, WritingBrush, extn_price_col, start_height + height_offset + (row_count * data_height)); row_count++; height_offset += 15; e.Graphics.DrawString("Freight", f, WritingBrush, start_margin, start_height + height_offset + (row_count * data_height)); e.Graphics.DrawString(needsCallQuote ? CFQ : "$" + String.Format("{0:0.00}", (Ref_Order != null ? Ref_Order.FreightCost : parent.currentFreightCost)), f_minor, WritingBrush, extn_price_col, start_height + height_offset + (row_count * data_height)); row_count++; row_count++; row_count++; // Resize panel bufferedPanel1.AutoScrollMinSize = new Size(bufferedPanel3.Width, start_height + height_offset + row_count * data_height); // Force resize only if too big if (start_height + height_offset + row_count * data_height > bufferedPanel1.Height) { bufferedPanel3.Height = new Size(bufferedPanel1.Width, start_height + height_offset + row_count * data_height).Height; } // Adjust surcharge value surchargeText.Text = "Total steel surcharge included: " + "$" + String.Format("{0:0.00}", surcharge_total); // Dispose all objects p.Dispose(); Grey_Pen.Dispose(); GreenBrush.Dispose(); RedBrush.Dispose(); GreyBrush.Dispose(); WritingBrush.Dispose(); f_minor.Dispose(); f.Dispose(); f_strike.Dispose(); f_total.Dispose(); f_header.Dispose(); f_italic.Dispose(); f_10_bold.Dispose(); f_9_bold.Dispose(); f_10.Dispose(); f_9.Dispose(); f_12_bold.Dispose(); f_14_bold.Dispose(); Invalidate(); }