Esempio n. 1
0
        private void tB2_TextChanged(object sender, EventArgs e)
        {
            TextBox RefBox = (TextBox)sender;

            try
            {
                DieCharge RefCharge = Ref_List[Convert.ToInt32(RefBox.Name.Substring(1))];
                RefCharge.Quantity = Convert.ToInt32(RefBox.Text);

                Label RefLabel = Label_List.First(x => x.Name == "p" + RefBox.Name.Substring(1));

                RefLabel.Text = "$" + String.Format("{0:0.00}", parent.Charge_Dictionary[Cur_DieType].FirstOrDefault(x => x.Name == RefCharge.Name).GetAdditionalCost(Cur_BasePrice) * RefCharge.Quantity);

                if (RefLabel.Text == "$0")
                {
                    RefLabel.ForeColor = Color.White;
                }
                else
                {
                    RefLabel.ForeColor = Color.LightGreen;
                }
            }
            catch
            {
                if (RefBox.Text.Length > 0)
                {
                    Grey_Out();
                    Form_Message_Box FMB = new Form_Message_Box(parent, "Invalid Quantity", true, -20, this.Location, this.Size);
                    FMB.ShowDialog();
                    Grey_In();
                    RefBox.Text = "";
                }
            }
        }
Esempio n. 2
0
        private void addSolidButton_Click(object sender, EventArgs e)
        {
            if (dieNo.Text.Length > 0 && dia.Text.Length > 0 && thk.Text.Length > 0)
            {
                Support support = new Support()
                {
                    DieType        = dt,
                    OrderID        = parent.randomID,
                    DieNo          = dieNo.Text + (copy.Text.Length > 0 ? "--" + copy.Text : ""),
                    Diameter       = Convert.ToDouble(dia.Text) / MetricFactor,
                    InnerDiameter  = 0,
                    Thickness      = Convert.ToDouble(thk.Text) / MetricFactor,
                    OddDiameter    = Ref_BaseCharge.Diameter,
                    OddThickness   = Ref_BaseCharge.Thickness,
                    HoleCount      = Convert.ToInt32(cavities.Text),
                    SurchargePrice = parent.GetSurchargeWeight(0, dt, Ref_BaseCharge.Diameter, Ref_BaseCharge.Thickness, 1, 0) * parent.surchargeRate,
                    Location       = location.Text,
                    Notes          = notes.Replace(Environment.NewLine, "```"),
                    CavityPrice    = current_cav_price,
                    Charge_List    = DieCharge_List,
                    BasePrice      = Calculate_Die_Price(),
                    isMetric       = Ref_Support != null ? Ref_Support.isMetric : parent.isMetric
                };

                if (Ref_Support != null)
                {
                    parent.Support_List.Insert(parent.Support_List.IndexOf(Ref_Support), support);
                    parent.Support_List.Remove(Ref_Support);
                }
                else
                {
                    parent.Support_List.Add(support);
                }
                this.Close();
            }
            else
            {
                Grey_Out();
                string error_message = "";
                if (dieNo.Text == "")
                {
                    error_message = "Error: Missing Die Number";
                }
                else if (dia.Text == "")
                {
                    error_message = "Error: Missing Diameter";
                }
                else if (thk.Text == "")
                {
                    error_message = "Error: Missing Thickness";
                }
                Form_Message_Box FMB = new Form_Message_Box(parent, error_message, true, -25, this.Location, this.Size);
                FMB.ShowDialog();
                Grey_In();
            }
        }
        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 helpButton_Click(object sender, EventArgs e)
        {
            Grey_Out();
            Form_Message_Box FMB = new Form_Message_Box(parent, "Formula for charges:" +
                                                        Environment.NewLine +
                                                        "F65 (Flat rate of 65)" + Environment.NewLine +
                                                        "F45 (Flat rate of 45)" + Environment.NewLine +
                                                        "B-0.23 (-23% of base price)" + Environment.NewLine +
                                                        "B0.73 (73% of base price)" + Environment.NewLine
                                                        , true, 35, this.Location, this.Size);

            FMB.ShowDialog();
            Grey_In();

            //180870875
        }
Esempio n. 5
0
        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();
        }
Esempio n. 7
0
        private void addSolidButton_Click(object sender, EventArgs e)
        {
            if (dieNo.Text.Length > 0 && dia.Text.Length > 0 && thk.Text.Length > 0)
            {
                Hollow hollow = new Hollow()
                {
                    OrderID        = parent.randomID,
                    DieNo          = dieNo.Text + (copy.Text.Length > 0 ? "--" + copy.Text : ""),
                    Diameter       = Convert.ToDouble(dia.Text) / MetricFactor,
                    Thickness      = Convert.ToDouble(thk.Text) / MetricFactor,
                    OddDiameter    = Ref_BaseCharge.Diameter,
                    OddThickness   = Ref_BaseCharge.Thickness,
                    SurchargePrice = parent.GetSurchargeWeight(0, dt, Ref_BaseCharge.Diameter, Ref_BaseCharge.Thickness, 1, 0) * parent.surchargeRate,
                    HoleCount      = Convert.ToInt32(cavities.Text),
                    Location       = location.Text,
                    Notes          = notes.Replace(Environment.NewLine, "```"),
                    Nitride        = nitride.Checked,
                    Charge_List    = DieCharge_List,
                    Plate_Only     = plate.Checked,
                    CavityPrice    = current_cav_price,
                    Mandrel_Only   = mandrel.Checked,
                    No_Backer      = backer.Checked,
                    BasePrice      = Calculate_Die_Price(),
                    isMetric       = Ref_Hollow != null ? Ref_Hollow.isMetric : parent.isMetric
                };

                if (exPart_backerLoc.Text.Length > 0 && exPart_backerPartno.Text.Length > 0 && exPart_backerCheck.Checked)
                {
                    hollow.FE_Backer_No  = exPart_backerPartno.Text;
                    hollow.FE_Backer_Loc = exPart_backerLoc.Text;
                }
                if (exPart_feederLoc.Text.Length > 0 && exPart_feederPartno.Text.Length > 0 && exPart_feederCheck.Checked)
                {
                    hollow.FE_Feeder_No  = exPart_feederPartno.Text;
                    hollow.FE_Feeder_Loc = exPart_feederLoc.Text;
                }
                if (exPart_bolsterLoc.Text.Length > 0 && exPart_bolsterPartno.Text.Length > 0 && exPart_bolsterCheck.Checked)
                {
                    hollow.FE_Bolster_No  = exPart_bolsterPartno.Text;
                    hollow.FE_Bolster_Loc = exPart_bolsterLoc.Text;
                }
                if (exPart_subbolsterLoc.Text.Length > 0 && exPart_subbolsterPartno.Text.Length > 0 && exPart_subbolsterCheck.Checked)
                {
                    hollow.FE_SubBol_No  = exPart_subbolsterPartno.Text;
                    hollow.FE_SubBol_Loc = exPart_subbolsterLoc.Text;
                }

                if (Ref_Hollow != null)
                {
                    parent.Hollow_List.Insert(parent.Hollow_List.IndexOf(Ref_Hollow), hollow);
                    parent.Hollow_List.Remove(Ref_Hollow);
                }
                else
                {
                    parent.Hollow_List.Add(hollow);
                }
                this.Close();
            }
            else
            {
                Grey_Out();
                string error_message = "";
                if (dieNo.Text == "")
                {
                    error_message = "Error: Missing Die Number";
                }
                else if (dia.Text == "")
                {
                    error_message = "Error: Missing Diameter";
                }
                else if (thk.Text == "")
                {
                    error_message = "Error: Missing Thickness";
                }
                Form_Message_Box FMB = new Form_Message_Box(parent, error_message, true, -25, this.Location, this.Size);
                FMB.ShowDialog();
                Grey_In();
            }
        }
Esempio n. 8
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();
        }