Пример #1
0
        //constructor taking a passed in id, will use this to create and populate a quote given an id
       public Quote(string id, string mode)
       {
           ops = new List<MachineOperation>();
           QuoteID = id;

           #region quote table
           //get everything from quote, then other tables
           DBConnection db = new DBConnection();
           string cmdString = "SELECT * from quote where QuoteID = '" + id + "'";

           if (db.OpenConnection())
           {
               MySqlCommand cmd = new MySqlCommand(cmdString, db.getConnection());
               MySqlDataReader dataReader = cmd.ExecuteReader();

               //loop through results, and pull out the info and save it to the quote object
               while (dataReader.Read())
               {
                   try
                   {
                       InfoID = Convert.ToInt32(dataReader["InfoID"].ToString());
                       CustID = dataReader["CustID"].ToString();
                       //get the date, db returns in mm/dd/yyyy so get that string
                       string date = dataReader["QuoteDate"].ToString();
                       //split it on the /, giving us "MM", "DD", "YYYY"
                       string[] datePieces = date.Split('/');
                       //the third piece will have the time, we need to pull that out, looks like "2015 12:00:00 AM", so split on space and pull first
                       string[] dayPieces = datePieces[2].Split(' ');
                       //create a new datetime out of the integer versions of those values (year, month, day)
                       int month = Convert.ToInt32(datePieces[0]);
                       int day = Convert.ToInt32(datePieces[1]);
                       int year = Convert.ToInt32(dayPieces[0]);
                       QuoteDate = new DateTime(year, month, day);
                       HrPerDay = Convert.ToDouble(dataReader["HrPerDay"].ToString());
                       SafeT = Convert.ToInt32(dataReader["SafeT"].ToString());                      
                   }
                   catch (Exception q) { }
               }

               //close everything
               dataReader.Close();
               db.CloseConnection();
           }
           #endregion
           #region quote_cost
           //quote_cost table
           try
           {
               cmdString = "SELECT * from quote_cost where QuoteID = '" + QuoteID + "' order by QtyID ASC";

               if (db.OpenConnection())
               {
                   MySqlCommand cmd = new MySqlCommand(cmdString, db.getConnection());
                   MySqlDataReader dataReader = cmd.ExecuteReader();

                   int rowCount = 1;
                   //loop through results, and pull out the info and save it to the quote object
                   while (dataReader.Read())
                   {
                       try
                       //each row gets a BreakDownQty, matcostX, bpcostx, coatcostx, and breakdownpct
                       {
                           if (rowCount == 1)
                           {
                               BreakDownQty1 = Convert.ToInt32(dataReader["Qty"].ToString());
                               matCost1 = Convert.ToDouble(dataReader["MatCost"].ToString());
                               BPCost1 = Convert.ToDouble(dataReader["BPCost"].ToString());
                               CoatCost1 = Convert.ToDouble(dataReader["CoatCost"].ToString());
                               BreakDownPct1 = Convert.ToDouble(dataReader["MarkUpPct"].ToString());
                           }
                           else if (rowCount == 2)
                           {
                               BreakDownQty2 = Convert.ToInt32(dataReader["Qty"].ToString());
                               matCost2 = Convert.ToDouble(dataReader["MatCost"].ToString());
                               BPCost2 = Convert.ToDouble(dataReader["BPCost"].ToString());
                               CoatCost2 = Convert.ToDouble(dataReader["CoatCost"].ToString());
                               BreakDownPct2 = Convert.ToDouble(dataReader["MarkUpPct"].ToString());
                           }
                           else if (rowCount == 3)
                           {
                               BreakDownQty3 = Convert.ToInt32(dataReader["Qty"].ToString());
                               matCost3 = Convert.ToDouble(dataReader["MatCost"].ToString());
                               BPCost3 = Convert.ToDouble(dataReader["BPCost"].ToString());
                               CoatCost3 = Convert.ToDouble(dataReader["CoatCost"].ToString());
                               BreakDownPct3 = Convert.ToDouble(dataReader["MarkUpPct"].ToString());
                           }
                           else if (rowCount == 4)
                           {
                               BreakDownQty4 = Convert.ToInt32(dataReader["Qty"].ToString());
                               matCost4 = Convert.ToDouble(dataReader["MatCost"].ToString());
                               BPCost4 = Convert.ToDouble(dataReader["BPCost"].ToString());
                               CoatCost4 = Convert.ToDouble(dataReader["CoatCost"].ToString());
                               BreakDownPct4 = Convert.ToDouble(dataReader["MarkUpPct"].ToString());
                           }
                           else if (rowCount == 5)
                           {
                               BreakDownQty5 = Convert.ToInt32(dataReader["Qty"].ToString());
                               matCost5 = Convert.ToDouble(dataReader["MatCost"].ToString());
                               BPCost5 = Convert.ToDouble(dataReader["BPCost"].ToString());
                               CoatCost5 = Convert.ToDouble(dataReader["CoatCost"].ToString());
                               BreakDownPct5 = Convert.ToDouble(dataReader["MarkUpPct"].ToString());
                           }
                           else if (rowCount == 6)
                           {
                               BreakDownQty6 = Convert.ToInt32(dataReader["Qty"].ToString());
                               matCost6 = Convert.ToDouble(dataReader["MatCost"].ToString());
                               BPCost6 = Convert.ToDouble(dataReader["BPCost"].ToString());
                               CoatCost6 = Convert.ToDouble(dataReader["CoatCost"].ToString());
                               BreakDownPct6 = Convert.ToDouble(dataReader["MarkUpPct"].ToString());
                           }
                           else if (rowCount == 7)
                           {
                               BreakDownQty7 = Convert.ToInt32(dataReader["Qty"].ToString());
                               matCost7 = Convert.ToDouble(dataReader["MatCost"].ToString());
                               BPCost7 = Convert.ToDouble(dataReader["BPCost"].ToString());
                               CoatCost7 = Convert.ToDouble(dataReader["CoatCost"].ToString());
                               BreakDownPct7 = Convert.ToDouble(dataReader["MarkUpPct"].ToString());
                           }
                       }
                       catch (Exception q) { }
                       rowCount++;
                   }

                   //close everything
                   dataReader.Close();
                   db.CloseConnection();
               }
           }
           catch (Exception q) { }
           #endregion
           

          //quote_info table? I dont think i need to do anything here because all its storing is references for the customer/job ids which be shown
           // so i will only need to worry about this table when inserting, but not selecting

           #region tool_info
           //tool_info table
           cmdString = "SELECT * from tool_info where InfoID = '" + InfoID + "'";

           if (db.OpenConnection())
           {
               MySqlCommand cmd = new MySqlCommand(cmdString, db.getConnection());
               MySqlDataReader dataReader = cmd.ExecuteReader();

               //loop through results, and pull out the info and save it to the quote object
               while (dataReader.Read())
               {
                   ToolType = dataReader["ToolType"].ToString();
                   OtherToolName = dataReader["OtherToolName"].ToString();
                   CoolThru = Convert.ToChar(dataReader["CoolThru"].ToString());
                   ShankDiam = dataReader["ShankDiam"].ToString();
                   OAL = dataReader["OAL"].ToString();
                   NoOfFlute = dataReader["NoOfFlute"].ToString();
                   FluteLength = dataReader["FluteLength"].ToString();
                   NoOfStep = dataReader["NoOfStep"].ToString();
                   NoOfProf = dataReader["NoOfProf"].ToString();
                   Description = dataReader["Description"].ToString();
                   AdminNote = dataReader["AdminNote"].ToString();
                   MatVend = dataReader["MatVend"].ToString();
                   MatOrderNo = dataReader["MatOrderNo"].ToString();
                   MatDesc = dataReader["MatDesc"].ToString();
                   MatSize = dataReader["MatSize"].ToString();
                   MatGrade = dataReader["MatGrade"].ToString();
                   MatLeadT = Convert.ToInt32(dataReader["MatLeadT"].ToString());
                   BPVend = dataReader["BPVend"].ToString();
                   BPDesc = dataReader["BPDesc"].ToString();
                   BPLeadT = Convert.ToInt32(dataReader["BPLeadT"].ToString());
                   UseCoating = Convert.ToChar(dataReader["Coating"].ToString());
                   CoatVend = dataReader["CoatVend"].ToString();
                   CoatDesc = dataReader["CoatDesc"].ToString();
                   CoatLeadT = Convert.ToInt32(dataReader["CoatLeadT"].ToString());
                   ToolNotes = dataReader["ToolNotes"].ToString();

                   //NEED CODE TO PULL DOWN IMAGE, LIKELY ANOTHER STATEMENT USING ADAPTERS
               }

               //close everything
               dataReader.Close();
               db.CloseConnection();

           }
           #endregion

           #region drill_step
           try
           {
               //drill step table

               if (db.OpenConnection())
               {
                   cmdString = "SELECT * from drill_step where InfoID = '" + InfoID + "' order by StepNo ASC";

                   MySqlCommand cmd = new MySqlCommand(cmdString, db.getConnection());
                   MySqlDataReader dataReader = cmd.ExecuteReader();

                   int rowCount = 1;
                   //loop through results, and pull out the info and save it to the quote object
                   while (dataReader.Read())
                   {
                       if (rowCount == 1)
                       {
                           step1Dia = dataReader["StepDiam"].ToString();
                           step1Length = dataReader["StepLeng"].ToString();
                           step1Angle = dataReader["StepDiam"].ToString();
                       }
                       else if (rowCount == 2)
                       {
                           step2Dia = dataReader["StepDiam"].ToString();
                           step2Length = dataReader["StepLeng"].ToString();
                           step2Angle = dataReader["StepDiam"].ToString();
                       }

                       else if (rowCount == 3)
                       {
                           step3Dia = dataReader["StepDiam"].ToString();
                           step3Length = dataReader["StepLeng"].ToString();
                           step3Angle = dataReader["StepDiam"].ToString();
                       }
                       rowCount++;
                   }

                   //close everything
                   dataReader.Close();
                   db.CloseConnection();
               }
           }
           catch (Exception q) { }
           #endregion

           #region mach_op
           try
           {
               if (db.OpenConnection())
               {
                   cmdString = "SELECT * from mach_op where InfoID = " + InfoID + " order by OpNo ASC";

                   MySqlCommand cmd = new MySqlCommand(cmdString, db.getConnection());
                   MySqlDataReader dataReader = cmd.ExecuteReader();
                   MachineOperation newOp;

                   //loop through results, and pull out the info and save it to the machineop object
                   while (dataReader.Read())
                   {
                       try
                       {
                           int number = Convert.ToInt32(dataReader["OpNo"].ToString());
                           newOp = new MachineOperation(InfoID, number);
                           newOp.MachID = Convert.ToInt32(dataReader["MachID"].ToString());
                           newOp.OpLevel = Convert.ToInt32(dataReader["OpLevel"].ToString());
                           newOp.SetupT = Convert.ToDouble(dataReader["SetupT"].ToString());
                           newOp.CyclT = Convert.ToDouble(dataReader["CyclT"].ToString());
                           newOp.LdUldT = Convert.ToDouble(dataReader["LdUldT"].ToString());
                           newOp.TBtwnOps = Convert.ToDouble(dataReader["TBtwnOps"].ToString());
                           newOp.Description = dataReader["Description"].ToString();
                           newOp.EffPct = Convert.ToDouble(dataReader["EffPct"].ToString());
                           newOp.OpAttPct = Convert.ToDouble(dataReader["OpAttPct"].ToString());
                           newOp.MachHrCst = Convert.ToDouble(dataReader["MachHrCst"].ToString());
                           ops.Add(newOp);
                       }
                       catch (Exception q)
                       {

                       }
                   }

                   //close everything
                   dataReader.Close();
                   db.CloseConnection();

                   foreach (MachineOperation op in ops)
                   {
                       op.setMathFactors();
                   }
               }
           }
           catch (Exception q) { }
           #endregion

           #region quoteimage
           //get the quoteimage

           if(db.OpenConnection())
           {
               cmdString = "SELECT ToolImage from tool_info where InfoID = " + InfoID;

               MySqlCommand cmd = new MySqlCommand(cmdString, db.getConnection());
               MySqlDataReader dataReader = cmd.ExecuteReader();
               MachineOperation newOp;

               //loop through results, and pull out the info and save it to the machineop object
               while (dataReader.Read())
               {
                   try
                   {
                       ToolImage = (byte[]) dataReader["ToolImage"];
                   }
                   catch (Exception q)
                   {

                   }
               }
                   
           }
           #endregion

       }
Пример #2
0
 private void btnSaveOperations_Click(object sender, EventArgs e)
 {
     localQuote.ops.Clear();
     if (numOperations >= 1)
     {
         MachineOperation newOp = new MachineOperation(localQuote.InfoID, 1);
         newOp.MachID = getMachineIdFromName(cmbOp1Machine.Text);
         newOp.OpLevel = Convert.ToInt32(cmbOp1Operator.Text);
         newOp.SetupT = Convert.ToDouble(txtOp1Setup.Text);
         newOp.CyclT = Convert.ToDouble(txtOp1Cycle.Text);
         newOp.LdUldT = Convert.ToDouble(txtOp1Load.Text);
         newOp.EffPct = Convert.ToDouble(txtOp1Efficiency.Text);
         newOp.OpAttPct = Convert.ToDouble(txtOp1OpAttend.Text);
         newOp.TBtwnOps = Convert.ToDouble(txtOp1TimeBetween.Text);
         newOp.MachHrCst = Convert.ToDouble(txtOp1MachineCost.Text);
         newOp.Description = txtOp1Description.Text;
         if (opsAtLoad < 1)
         {
             newOp.Upload();
         }
         localQuote.ops.Add(newOp);
     }
     if (numOperations >= 2)
     {
         MachineOperation newOp = new MachineOperation(localQuote.InfoID, 2);
         newOp.MachID = getMachineIdFromName(cmbOp2Machine.Text);
         newOp.OpLevel = Convert.ToInt32(cmbOp2Operator.Text);
         newOp.SetupT = Convert.ToDouble(txtOp2Setup.Text);
         newOp.CyclT = Convert.ToDouble(txtOp2Cycle.Text);
         newOp.LdUldT = Convert.ToDouble(txtOp2Load.Text);
         newOp.EffPct = Convert.ToDouble(txtOp2Efficiency.Text);
         newOp.OpAttPct = Convert.ToDouble(txtOp2OpAttend.Text);
         newOp.TBtwnOps = Convert.ToDouble(txtOp2TimeBetween.Text);
         newOp.MachHrCst = Convert.ToDouble(txtOp2MachineCost.Text);
         newOp.Description = txtOp2Description.Text;
         if(opsAtLoad < 2)
         {
             newOp.Upload();
         }
         localQuote.ops.Add(newOp);
     }
     if (numOperations >= 3)
     {
         MachineOperation newOp = new MachineOperation(localQuote.InfoID, 3);
         newOp.MachID = getMachineIdFromName(cmbOp3Machine.Text);
         newOp.OpLevel = Convert.ToInt32(cmbOp3Operator.Text);
         newOp.SetupT = Convert.ToDouble(txtOp3Setup.Text);
         newOp.CyclT = Convert.ToDouble(txtOp3Cycle.Text);
         newOp.LdUldT = Convert.ToDouble(txtOp3Load.Text);
         newOp.EffPct = Convert.ToDouble(txtOp3Efficiency.Text);
         newOp.OpAttPct = Convert.ToDouble(txtOp3OpAttend.Text);
         newOp.TBtwnOps = Convert.ToDouble(txtOp3TimeBetween.Text);
         newOp.MachHrCst = Convert.ToDouble(txtOp3MachineCost.Text);
         newOp.Description = txtOp3Description.Text;
         if (opsAtLoad < 3)
         {
             newOp.Upload();
         }
         localQuote.ops.Add(newOp);
     }
     if (numOperations >= 4)
     {
         MachineOperation newOp = new MachineOperation(localQuote.InfoID, 4);
         newOp.MachID = getMachineIdFromName(cmbOp4Machine.Text);
         newOp.OpLevel = Convert.ToInt32(cmbOp4Operator.Text);
         newOp.SetupT = Convert.ToDouble(txtOp4Setup.Text);
         newOp.CyclT = Convert.ToDouble(txtOp4Cycle.Text);
         newOp.LdUldT = Convert.ToDouble(txtOp4Load.Text);
         newOp.EffPct = Convert.ToDouble(txtOp4Efficiency.Text);
         newOp.OpAttPct = Convert.ToDouble(txtOp4OpAttend.Text);
         newOp.TBtwnOps = Convert.ToDouble(txtOp4TimeBetween.Text);
         newOp.MachHrCst = Convert.ToDouble(txtOp4MachineCost.Text);
         newOp.Description = txtOp4Description.Text;
         if (opsAtLoad < 4)
         {
             newOp.Upload();
         }
         localQuote.ops.Add(newOp);
     }
     if (numOperations >= 5)
     {
         MachineOperation newOp = new MachineOperation(localQuote.InfoID, 5);
         newOp.MachID = getMachineIdFromName(cmbOp5Machine.Text);
         newOp.OpLevel = Convert.ToInt32(cmbOp5Operator.Text);
         newOp.SetupT = Convert.ToDouble(txtOp5Setup.Text);
         newOp.CyclT = Convert.ToDouble(txtOp5Cycle.Text);
         newOp.LdUldT = Convert.ToDouble(txtOp5Load.Text);
         newOp.EffPct = Convert.ToDouble(txtOp5Efficiency.Text);
         newOp.OpAttPct = Convert.ToDouble(txtOp5OpAttend.Text);
         newOp.TBtwnOps = Convert.ToDouble(txtOp5TimeBetween.Text);
         newOp.MachHrCst = Convert.ToDouble(txtOp5MachineCost.Text);
         newOp.Description = txtOp5Description.Text;
         if (opsAtLoad < 5)
         {
             newOp.Upload();
         }
         localQuote.ops.Add(newOp);
     }
     if (numOperations >= 6)
     {
         MachineOperation newOp = new MachineOperation(localQuote.InfoID, 6);
         newOp.MachID = getMachineIdFromName(cmbOp6Machine.Text);
         newOp.OpLevel = Convert.ToInt32(cmbOp6Operator.Text);
         newOp.SetupT = Convert.ToDouble(txtOp6Setup.Text);
         newOp.CyclT = Convert.ToDouble(txtOp6Cycle.Text);
         newOp.LdUldT = Convert.ToDouble(txtOp6Load.Text);
         newOp.EffPct = Convert.ToDouble(txtOp6Efficiency.Text);
         newOp.OpAttPct = Convert.ToDouble(txtOp6OpAttend.Text);
         newOp.TBtwnOps = Convert.ToDouble(txtOp6TimeBetween.Text);
         newOp.MachHrCst = Convert.ToDouble(txtOp6MachineCost.Text);
         newOp.Description = txtOp6Description.Text;
         if (opsAtLoad < 6)
         {
             newOp.Upload();
         }
         localQuote.ops.Add(newOp);
     }
     if (numOperations >= 7)
     {
         MachineOperation newOp = new MachineOperation(localQuote.InfoID, 7);
         newOp.MachID = getMachineIdFromName(cmbOp7Machine.Text);
         newOp.OpLevel = Convert.ToInt32(cmbOp7Operator.Text);
         newOp.SetupT = Convert.ToDouble(txtOp7Setup.Text);
         newOp.CyclT = Convert.ToDouble(txtOp7Cycle.Text);
         newOp.LdUldT = Convert.ToDouble(txtOp7Load.Text);
         newOp.EffPct = Convert.ToDouble(txtOp7Efficiency.Text);
         newOp.OpAttPct = Convert.ToDouble(txtOp7OpAttend.Text);
         newOp.TBtwnOps = Convert.ToDouble(txtOp7TimeBetween.Text);
         newOp.MachHrCst = Convert.ToDouble(txtOp7MachineCost.Text);
         newOp.Description = txtOp7Description.Text;
         if (opsAtLoad < 7)
         {
             newOp.Upload();
         }
         localQuote.ops.Add(newOp);
     }
     this.Hide();
 }