private void Print() { using (var form = new Yes_No_Dialog(parent, "Are you sure you want to print this purchase order?", "Warning", "No", "Yes", 0, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { if (secondThreadFormHandle == IntPtr.Zero) { Loading_Form form2 = new Loading_Form(parent, this.Location, this.Size, "PRINTING", "PDF") { }; form2.HandleCreated += SecondFormHandleCreated; form2.HandleDestroyed += SecondFormHandleDestroyed; form2.RunInNewThread(false); } PDFGenerator PDFG = new PDFGenerator(parent, externalID.Length > 0 ? externalID : parent.CurrentID, externalID.Length > 0, externalID.Length > 0 ? externalID : parent.CurrentID); string pdfPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), (externalID.Length > 0 ? externalID : parent.CurrentID) + ".pdf"); ProcessStartInfo info = new ProcessStartInfo(); info.Verb = "print"; info.FileName = pdfPath; info.CreateNoWindow = true; info.WindowStyle = ProcessWindowStyle.Hidden; Process p = new Process(); p.StartInfo = info; p.Start(); p.WaitForInputIdle(); System.Threading.Thread.Sleep(3000); if (false == p.CloseMainWindow()) { p.Kill(); } try { File.Delete(pdfPath); } catch { Console.WriteLine("Error deleting print image file"); } if (secondThreadFormHandle != IntPtr.Zero) { PostMessage(secondThreadFormHandle, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } } } }
private void button1_Click(object sender, EventArgs e) { Grey_Out(); if (Checked_Items.Count > 0) { Application.DoEvents(); using (var form = new Yes_No_Dialog(parent, "Are you sure you want to create " + Checked_Items.Count + " purchase order PDF(s)?", "Warning", "No", "Yes", 0, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { if (secondThreadFormHandle == IntPtr.Zero) { Loading_Form form2 = new Loading_Form(parent, this.Location, this.Size, "GENERATING", "PDF(s)") { }; form2.HandleCreated += SecondFormHandleCreated; form2.HandleDestroyed += SecondFormHandleDestroyed; form2.RunInNewThread(false); } Checked_Items.ForEach(x => new PDFGenerator(parent, x, true)); //PDFGenerator PDFG = new PDFGenerator(parent, parent.CurrentID, false); if (secondThreadFormHandle != IntPtr.Zero) { PostMessage(secondThreadFormHandle, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } deselectAll.PerformClick(); } } } else { Form_Message_Box FMB = new Form_Message_Box(parent, "No orders selected", true, -25, this.Location, this.Size); FMB.ShowDialog(); } Grey_In(); }
private void addSolidButton_Click(object sender, EventArgs e) { Grey_Out(); using (var form = new Yes_No_Dialog(parent, "Are you sure you wish to import ALL associated charges for current part? This might include a lot of miscellaneous part charges. Continue?", "Warning", "No", "Yes", 45, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { // Select database using (var DBS = new DatabaseSelector(parent, null, "Select Database", this.Location, this.Size, true)) { var returnv = DBS.ShowDialog(); // If database valid if (returnv == DialogResult.OK && DBS.dbName.Length > 0) { setDatabase(DBS.dbName);// Force form to redraw #region Get All Customers Customer_List = new List <Customer>(); string query = "select customercode, name, pricelist from d_customer"; instance.Open(masterDB); OdbcDataReader reader = instance.RunQuery(query); while (reader.Read()) { Customer c = new Customer(); c.custCode = reader[0].ToString().Trim(); c.Name = reader[1].ToString().Trim(); c.PLCode = reader[2].ToString().Trim(); Customer_List.Add(c); } reader.Close(); #endregion Application.DoEvents(); // Get customer Get_Customers(); Grey_Out(); if (secondThreadFormHandle == IntPtr.Zero) { Loading_Form form2 = new Loading_Form(parent, this.Location, this.Size, "IMPORTING", "DATABASE") { }; form2.HandleCreated += SecondFormHandleCreated; form2.HandleDestroyed += SecondFormHandleDestroyed; form2.RunInNewThread(false); } // Generate price list Import_Charges(); if (secondThreadFormHandle != IntPtr.Zero) { PostMessage(secondThreadFormHandle, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } Form_Message_Box FMB = new Form_Message_Box(parent, "Import Successful!", true, -28, this.Location, this.Size); FMB.ShowDialog(); Grey_In(); } } } } Grey_In(); }
private double Calculate_Die_Price(bool silent = false) { if (Loaded) { this.Height = panel1.Visible ? 512 : 412; TFLP.Size = new Size(this.Width - 2, this.Height - 2); if (!silent) { Grey_Out(); Application.DoEvents(); if (secondThreadFormHandle == IntPtr.Zero) { Loading_Form form2 = new Loading_Form(parent, this.Location, this.Size, "CALCULATING", "PRICE") { }; form2.HandleCreated += SecondFormHandleCreated; form2.HandleDestroyed += SecondFormHandleDestroyed; form2.RunInNewThread(false); } } bool Error = false; bool Rework = false; double price = 0; double weight = 0; try { price = Ref_BaseCharge.Price; current_cav_price = 0; // If base price is 0, error if (price == 0) { Error = true; } Console.WriteLine(Ref_BaseCharge.ToString()); // Get hole charge if (cavities.Text != "1" && ((refHoleCharges != null && refHoleCharges.holeQty != Convert.ToInt32(cavities.Text)) || refHoleCharges == null)) { refHoleCharges = parent.holeCharge_List.FirstOrDefault(x => (x.holeQty == Convert.ToInt32(cavities.Text)) && x.Diameter == Ref_BaseCharge.Diameter && x.Thickness == Ref_BaseCharge.Thickness && x.Prefix == parent.Get_Die_Prefix(dt)); price += refHoleCharges.Price * refHoleCharges.holeQty; current_cav_price = refHoleCharges.Price * refHoleCharges.holeQty; } else if (cavities.Text != "1") { price += refHoleCharges.Price * refHoleCharges.holeQty; current_cav_price = refHoleCharges.Price * refHoleCharges.holeQty; } // Get special charges additionalCharges.Text = ""; string passText = ""; foreach (DieCharge DC in DieCharge_List) { if (DC.Name.ToLower().Contains("rework") && DC.Quantity > 0) { Rework = true; price += DC.GetAdditionalCost(Ref_BaseCharge.Price + current_cav_price); // Only allow one quantity of rework passText += ", " + DC.Name + " (" + DC.Quantity + ")"; } else if (DC.Quantity > 0) { price += DC.GetAdditionalCost(Ref_BaseCharge.Price + current_cav_price) * DC.Quantity; passText += ", " + DC.Name + " (" + DC.Quantity + ")"; } } if (passText.Length > 2) { additionalCharges.Text = passText.Substring(2); } if (passText.Length > 150) { additionalCharges.ScrollBars = ScrollBars.Vertical; } Console.WriteLine("Base Price = " + price); // Get surcharge price GetSurchargeWeight(0, dt, Ref_BaseCharge.Diameter, Ref_BaseCharge.Thickness, 1, out weight); price += parent.surchargeRate * weight; // Get Nitride cost if checked if (nitride.Checked) { price += parent.GetFreightWeight("", dt, Convert.ToDouble(dia.Text) / MetricFactor, Convert.ToDouble(thk.Text) / MetricFactor, 0) * parent.nitrideRate; } // Nitride cost off actual size instead of odd size //if (nitride.Checked) // price += parent.GetFreightWeight("",dt, Ref_BaseCharge.Diameter, Ref_BaseCharge.Thickness, 0) * parent.nitrideRate; if (plate.Checked) { price += 50; } surchargeLabel.Text = "Steel Surcharge: $" + String.Format("{0:0.00}", parent.surchargeRate * weight) + " (" + Math.Round(weight, 2) + "lbs @ $" + String.Format("{0:0.00}", parent.surchargeRate) + "/lb)"; totalLabel.Text = "Total: $" + String.Format("{0:0.00}", price); } catch { Error = true; } if (!silent) { Grey_In(); if (secondThreadFormHandle != IntPtr.Zero) { PostMessage(secondThreadFormHandle, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } } if (Error || (!Rework && (price - parent.surchargeRate * weight) == 0) || (plate.Checked || mandrel.Checked || backer.Checked)) { surchargeLabel.Text = ""; totalLabel.Text = "Please call in for quote"; return(0); } else { Console.WriteLine("Price = " + price); return(price); } } return(0); }
private void button2_Click(object sender, EventArgs e) { Grey_Out(); if (Checked_Items.Count > 0) { Application.DoEvents(); using (var form = new Yes_No_Dialog(parent, "Are you sure you want to print " + Checked_Items.Count + " purchase order PDF(s)?", "Warning", "No", "Yes", 0, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { if (secondThreadFormHandle == IntPtr.Zero) { Loading_Form form2 = new Loading_Form(parent, this.Location, this.Size, "PRINTING", "PDF(s)") { }; form2.HandleCreated += SecondFormHandleCreated; form2.HandleDestroyed += SecondFormHandleDestroyed; form2.RunInNewThread(false); } foreach (string g in Checked_Items) { PDFGenerator PDFG = new PDFGenerator(parent, g, true, g); string pdfPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), g + ".pdf"); ProcessStartInfo info = new ProcessStartInfo(); info.Verb = "print"; info.FileName = pdfPath; info.CreateNoWindow = true; info.WindowStyle = ProcessWindowStyle.Hidden; Process p = new Process(); p.StartInfo = info; p.Start(); p.WaitForInputIdle(); System.Threading.Thread.Sleep(3000); if (false == p.CloseMainWindow()) { p.Kill(); } try { File.Delete(pdfPath); } catch { Console.WriteLine("Error deleting print image file"); } } if (secondThreadFormHandle != IntPtr.Zero) { PostMessage(secondThreadFormHandle, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } deselectAll.PerformClick(); } } } else { Form_Message_Box FMB = new Form_Message_Box(parent, "No orders selected", true, -25, this.Location, this.Size); FMB.ShowDialog(); } Grey_In(); }
private double Calculate_Die_Price(bool silent = false) { if (Loaded) { this.Height = panel1.Visible ? 512 : 412; TFLP.Size = new Size(this.Width - 2, this.Height - 2); if (!silent) { Grey_Out(); Application.DoEvents(); if (secondThreadFormHandle == IntPtr.Zero) { Loading_Form form2 = new Loading_Form(parent, this.Location, this.Size, "CALCULATING", "PRICE") { }; form2.HandleCreated += SecondFormHandleCreated; form2.HandleDestroyed += SecondFormHandleDestroyed; form2.RunInNewThread(false); } } bool Error = false; bool Rework = false; double price = 0; double weight = 0; try { price = Ref_BaseCharge.Price; current_cav_price = 0; // If base price is 0, error if (price == 0 || Ref_BaseCharge.InnerDiameter - 1 > Ref_BaseCharge.Diameter) { Error = true; } Console.WriteLine(Ref_BaseCharge.ToString()); // Get special charges additionalCharges.Text = ""; string passText = ""; foreach (DieCharge DC in DieCharge_List) { if (DC.Name.ToLower().Contains("rework") && DC.Quantity > 0) { Rework = true; price += DC.GetAdditionalCost(Ref_BaseCharge.Price + current_cav_price); // Only allow one quantity of rework passText += ", " + DC.Name + " (" + DC.Quantity + ")"; } else if (DC.Quantity > 0) { price += DC.GetAdditionalCost(Ref_BaseCharge.Price + current_cav_price) * DC.Quantity; passText += ", " + DC.Name + " (" + DC.Quantity + ")"; } } if (passText.Length > 2) { additionalCharges.Text = passText.Substring(2); } if (passText.Length > 150) { additionalCharges.ScrollBars = ScrollBars.Vertical; } Console.WriteLine("Base Price = " + price); // Get surcharge price GetSurchargeWeight(0, dt, Ref_BaseCharge.Diameter, Ref_BaseCharge.Thickness, 1, out weight); price += parent.surchargeRate * weight; surchargeLabel.Text = "Steel Surcharge: $" + String.Format("{0:0.00}", parent.surchargeRate * weight) + " (" + Math.Round(weight, 2) + "lbs @ $" + String.Format("{0:0.00}", parent.surchargeRate) + "/lb)"; totalLabel.Text = "Total: $" + String.Format("{0:0.00}", price); } catch { Error = true; } if (!silent) { Grey_In(); if (secondThreadFormHandle != IntPtr.Zero) { PostMessage(secondThreadFormHandle, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } } if (Error || (!Rework && (price - parent.surchargeRate * weight) == 0)) { surchargeLabel.Text = ""; totalLabel.Text = "Please call in for quote"; return(0); } else { Console.WriteLine("Price = " + price); return(price); } } return(0); }