private void createPOButton_Click(object sender, EventArgs e) { Grey_Out(); if (parent.Auth == "" || parent.Req == "" || parent.Due == "" || parent.PO == "") { Form_Message_Box FMB = new Form_Message_Box(parent, "Error: Missing header information", true, -15, this.Location, this.Size); FMB.ShowDialog(); } else { using (var form = new Yes_No_Dialog(parent, "Once generated, you are not able to make any changes to the order. Continue?", "Warning", "No", "Yes", 10, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { // Create order Order o = new Order() { Date = DateTime.Now, Total = parent.Current_Order_Total, DieQty = parent.Solid_List.Count + parent.Hollow_List.Count + parent.Support_List.Count, ID = parent.randomID, Authorizer = parent.Auth, PO = parent.PO, Requisitioner = parent.Req, FreightCost = parent.currentFreightCost, Due = parent.Due }; // Set order date to now parent.Solid_List.ForEach(x => x.OrderDate = DateTime.Now); parent.Hollow_List_History.ForEach(x => x.OrderDate = DateTime.Now); parent.Support_List_History.ForEach(x => x.OrderDate = DateTime.Now); // Transfer to historical values parent.Solid_List_History.AddRange(parent.Solid_List); parent.Hollow_List_History.AddRange(parent.Hollow_List); parent.Support_List_History.AddRange(parent.Support_List); parent.Order_List.Add(o); // Save parent.Save_Information(); createPOButton.Enabled = false; parent.DisableEdit = true; parent.Background_Save(); parent.Invalidate(); this.Close(); } } } Grey_In(); }
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 clearPartsButton_Click(object sender, EventArgs e) { Grey_Out(); using (var form = new Yes_No_Dialog(parent, "Are you sure you want to clear history? This action is irreversable. Continue?", "Warning", "No", "Yes", 10, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { parent.Order_List = new List <Order>(); Invalidate(); parent.Background_Save(); this.Close(); } } Grey_In(); }
private void clearPartsButton_Click(object sender, EventArgs e) { Grey_Out(); using (var form = new Yes_No_Dialog(parent, "Are you sure you wish to clear form?", "Warning", "No", "Yes", -12, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { foreach (Control c in this.Controls) { if (!(c is Label || c is CheckBox || c is Button)) { c.Text = ""; } if (c is CheckBox) { ((CheckBox)c).Checked = false; } } foreach (Control c in this.panel1.Controls) { if (!(c is Label || c is CheckBox || c is Button)) { c.Text = ""; } if (c is CheckBox) { ((CheckBox)c).Checked = false; } } DieCharge_List = new List <DieCharge>(); totalLabel.Text = surchargeLabel.Text = notes = ""; if (panel1.Visible) { closeButton.PerformClick(); } this.Height = 356; } } Grey_In(); }
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 close_button_Click_1(object sender, EventArgs e) { Grey_Out(); if (Ref_BaseCharge != null && Ref_Hollow == null) { using (var form = new Yes_No_Dialog(parent, "Are you sure you want to close?", "Warning", "No", "Yes", -15, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { this.Dispose(); this.Close(); } } } else { this.Dispose(); this.Close(); } Grey_In(); }
private void button2_Click(object sender, EventArgs e) { Grey_Out(); using (var form = new Yes_No_Dialog(parent, "Are you sure you want to load default charges?", "Warning", "No", "Yes", 0, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { parent.Charge_Dictionary = new Dictionary <DieType, List <DieCharge> >(); List <DieCharge> DCListTemp = new List <DieCharge>(); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "F75", Name = "Bolts Hardened H13" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "F100", Name = "C Route" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B1", Name = "Hardened Blank" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B0.5", Name = "Heat Sink 50%" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B1", Name = "Heat Sink 100%" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "F50", Name = "Pocket Charge" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B0.25", Name = "Shut Off Die - Dovetail" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B0.15", Name = "Shut Off Die - Normal" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "F100", Name = "Special Polish" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "F100", Name = "Taper Cut Support" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "F150", Name = "Triple Skim Cut" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "F100", Name = "Wire Relief" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "F100", Name = "Zero Bearing" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B0.05", Name = "Complexity 5%" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B0.1", Name = "Complexity 10%" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B0.15", Name = "Complexity 15%" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B0.2", Name = "Complexity 20%" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "B0.3", Name = "Complexity 30%" }); DCListTemp.Add(new DieCharge(DieType.Solid) { Formula = "F150", Name = "Wire Support" }); parent.Charge_Dictionary.Add(DieType.Solid, DCListTemp); DCListTemp = new List <DieCharge>(); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F75", Name = "Bolts Hardened H13" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F0", Name = "Bridge Feeder" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F400", Name = "Butterfly Design" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F100", Name = "C Route" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.1", Name = "Center Feed Design" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F100", Name = "Choke" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.25", Name = "D Rung Die" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F200", Name = "Dome Dies" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.25", Name = "Extended Fixed Mandrel" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.05", Name = "Fake Core 5%" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B1", Name = "Hardened Blank" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.5", Name = "Heat Sink 50%" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B1", Name = "Heat Sink 100%" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.25", Name = "Insert for Mandrel" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "0.25", Name = "Insert for Plate" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F100", Name = "Per pc. replaceable Mandrel" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F300", Name = "Micro Bridge Charge" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F500", Name = "Mini-spider Insert" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F60", Name = "Nitrogen Grooves Backer" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.25", Name = "Once-piece die" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F150", Name = "Pin Cores" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.05", Name = "Semi-hollow" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.25", Name = "Shutoff Die - Dovetail" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.15", Name = "Shutoff Die - Normal" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F100", Name = "Special Polish" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F200", Name = "Spider-web Design" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F100", Name = "Taper Cut Support" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F150", Name = "Triple Skim Cut" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F100", Name = "Wire Relief" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F150", Name = "Wire Support" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "F100", Name = "Zero Bearing" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.05", Name = "Complexity 5%" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.1", Name = "Complexity 10%" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.15", Name = "Complexity 15%" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.2", Name = "Complexity 20%" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.3", Name = "Complexity 30%" }); DCListTemp.Add(new DieCharge(DieType.Hollow) { Formula = "B0.05", Name = "Multi-mandrel" }); parent.Charge_Dictionary.Add(DieType.Hollow, DCListTemp); DCListTemp = new List <DieCharge>(); DCListTemp.Add(new DieCharge(DieType.Feeder) { Formula = "F75", Name = "Bolts Hardened H13" }); parent.Charge_Dictionary.Add(DieType.Feeder, DCListTemp); DCListTemp = new List <DieCharge>(); DCListTemp.Add(new DieCharge(DieType.Backer) { Formula = "F75", Name = "Bolts Hardened H13" }); DCListTemp.Add(new DieCharge(DieType.Backer) { Formula = "F60", Name = "Nitrogen Grooves Backer" }); DCListTemp.Add(new DieCharge(DieType.Backer) { Formula = "F200", Name = "Taper Cut Backer" }); parent.Charge_Dictionary.Add(DieType.Backer, DCListTemp); DCListTemp = new List <DieCharge>(); DCListTemp.Add(new DieCharge(DieType.Bolster) { Formula = "F75", Name = "Bolts Hardened H13" }); DCListTemp.Add(new DieCharge(DieType.Bolster) { Formula = "F100", Name = "Nitrogen Grooves Bolster" }); parent.Charge_Dictionary.Add(DieType.Bolster, DCListTemp); DCListTemp = new List <DieCharge>(); DCListTemp.Add(new DieCharge(DieType.Subbolster) { Formula = "F75", Name = "Bolts Hardened H13" }); DCListTemp.Add(new DieCharge(DieType.Subbolster) { Formula = "F100", Name = "Nitrogen Grooves Bolster" }); parent.Charge_Dictionary.Add(DieType.Subbolster, DCListTemp); DCListTemp = new List <DieCharge>(); DCListTemp.Add(new DieCharge(DieType.Ring) { Formula = "F60", Name = "Nitrogen Inlet" }); DCListTemp.Add(new DieCharge(DieType.Ring) { Formula = "F100", Name = "Internal Keyway" }); parent.Charge_Dictionary.Add(DieType.Ring, DCListTemp); DCListTemp = new List <DieCharge>(); Populate_Charges(dieTypes.Text); } } 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 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 void dynamic_button_click(object sender, EventArgs e) { Button b = (Button)sender; Grey_Out(); if (b.Name.StartsWith("d")) //delete { using (var form = new Yes_No_Dialog(parent, "Are you sure you want to delete this order? Action cannot be undone. Continue?", "Warning", "No", "Yes", 10, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { parent.Order_List = parent.Order_List.Where(x => x.ID != b.Name.Substring(1)).ToList(); Invalidate(); parent.Background_Save(); if (parent.Order_List.Count == 0) { this.Close(); } } } } else if (b.Name.StartsWith("v")) //view { // save current header information string h1 = parent.Req; string h2 = parent.Auth; string h3 = parent.PO; string h4 = parent.Due; View_Current_Order H = new View_Current_Order(parent, this.Location, this.Size, false, b.Name.Substring(1)); H.ShowDialog(); // Restore to original parent.Req = h1; parent.Auth = h2; parent.PO = h3; parent.Due = h4; } else if (b.Name.StartsWith("c")) //check/uncheck { if (Checked_Items.Contains(b.Name.Substring(1))) { Checked_Items.Remove(b.Name.Substring(1)); } else { if (!Checked_Items.Contains(b.Name.Substring(1))) { Checked_Items.Add(b.Name.Substring(1)); } } Invalidate(); } else { using (var form = new Yes_No_Dialog(parent, "Are you sure you want to load this order? If you haven't created the PO for your current order, it will be lost. Continue?", "Warning", "No", "Yes", 33, this.Location, this.Size)) { var result = form.ShowDialog(); if (result == DialogResult.OK && form.ReturnValue1 == "1") { Order Ref_Order = parent.Order_List.First(x => x.ID == b.Name); parent.Req = Ref_Order.Requisitioner; parent.Auth = Ref_Order.Authorizer; parent.PO = Ref_Order.PO; parent.Due = Ref_Order.Due; parent.CurrentID = b.Name; parent.Solid_List = parent.Solid_List_History.Where(x => x.OrderID == b.Name).ToList(); parent.Hollow_List = parent.Hollow_List_History.Where(x => x.OrderID == b.Name).ToList(); parent.Support_List = parent.Support_List_History.Where(x => x.OrderID == b.Name).ToList(); parent.Invalidate(); parent.DisableEdit = true; this.Close(); } } } Grey_In(); }