Beispiel #1
0
        private void btnAddJob_Click(object sender, EventArgs e)
        {
            //take selected from listQuotesAndJobs
            //if job get the quoteid
            //create new job 

            //if quote then make folder and job
            try
            {
                string target = listQuotesAndJobs.SelectedItem.ToString();
                Job newjob;
                if (target.Substring(0, 1) == "Q" || chkRevision.Checked == true)
                {
                    newjob = new Job(target, chkRevision.Checked);
                    Quote targetQuote = new Quote(target, "load");
                    try
                    {
                        System.IO.Directory.CreateDirectory("C:\\xampp\\htdocs\\AcuTwistJobs\\" + newjob.myQuote.CustID + "\\" + newjob.JobID);
                    }
                    catch (Exception q)
                    {

                    }
                    DBConnection conn = new DBConnection();
                    if (conn.OpenConnection())
                    {
    
                            try
                            {
                                MySqlCommand command = conn.getConnection().CreateCommand();
                                command.CommandText = "UPDATE quote_info SET FirstJobID = '" + newjob.JobID + "' WHERE InfoID = '" + targetQuote.InfoID + "'";
                                command.ExecuteNonQuery();
                            }
                            catch (Exception q) { }
                        }
                        conn.CloseConnection();

                }
                else
                {
                    newjob = new Job(target, "load");
                }

                po.associatedJobs.Add(newjob);
                listAssociatedJobs.Items.Add(newjob.JobID);
                listJobs.Items.Add(newjob.JobID);
                po.PO_Status = cmbPOStatus.Text;
                po.SaveToDatabase();

                DBConnection connect = new DBConnection();
                if (connect.OpenConnection())
                {
                    foreach (string j in listAssociatedJobs.Items)
                    {
                        try
                        {
                            MySqlCommand command = connect.getConnection().CreateCommand();
                            command.CommandText = "INSERT INTO po_job(PO_No, JobID) VALUES(?PO_No, ?JobID)";

                            command.Parameters.Add("?PO_No", MySqlDbType.VarChar).Value = po.PO_No;
                            command.Parameters.Add("?JobID", MySqlDbType.VarChar).Value = j;
                            command.ExecuteNonQuery();
                        }
                        catch (Exception q) { }
                    }
                    connect.CloseConnection();
                }
                buildLists();
            }
            catch (Exception q) { }
        }
Beispiel #2
0
        private void btnViewQuote_Click(object sender, EventArgs e)
        {
            try
            {
                //launch quoteinfo page with a passed id and fill the form
                string target = listQuotesAndJobs.SelectedItem.ToString();

                //check to see if its a quote (will have Q in front)
                if (target.Substring(0, 1) != "Q")
                {
                    //if its not a quote its a job, but we need the quote
                    //so make a job object, it will fetch its quoteid
                    Job j = new Job(target, "load");
                    //then grab it
                    target = j.QuoteID;
                }

                NewQuoteInfo nq = new NewQuoteInfo(target, "display");
                nq.Show();
                nq.BringToFront();
            }
            catch(Exception q)
            { }
        }
Beispiel #3
0
 private void btnViewJobQuote_Click(object sender, EventArgs e)
 {
     string target = listJobs.SelectedItem.ToString();
     Job j = new Job(target, "load");
     target = j.QuoteID;
      
     NewQuoteInfo nq = new NewQuoteInfo(target, "display");
     nq.Show();
     nq.BringToFront();
 }
Beispiel #4
0
        //loading existing
        public PO (string number, string mode)
        {
            jobsToBuild = new List<string>();
            runsToBuild = new List<runInfo>();
            associatedJobs = new List<Job>();
            jobRuns = new List<JobRun>();
            saved = true;

            PO_No = number;

            #region PO info
            //get the po info
            DBConnection db = new DBConnection();
            //the query to run
            string cmdString = "SELECT * FROM po WHERE PO_No = '" + PO_No + "'";

            //open the connection and execute our query
            if (db.OpenConnection())
            {
                MySqlCommand cmd = new MySqlCommand(cmdString, db.getConnection());
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //grab the fields from the row
                while (dataReader.Read())
                {
                    try
                    {
                        CustID = dataReader["CustID"].ToString();
                        //get the date, db returns in mm/dd/yyyy so get that string
                        string date = dataReader["PO_Date"].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]);
                        PO_Date = new DateTime(year, month, day);
                        PO_Status = dataReader["PO_Status"].ToString();
                    }
                    catch (Exception q)
                    {

                    }
                }
                //close everything
                dataReader.Close();
                db.CloseConnection();
            }
            #endregion

            #region Associated Jobs
            db = new DBConnection();
            //the query to run
            cmdString = "SELECT JobID FROM po_job WHERE PO_No = '" + PO_No + "'";

            //open the connection and execute our query
            if (db.OpenConnection())
            {
                MySqlCommand cmd = new MySqlCommand(cmdString, db.getConnection());
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //grab the fields from the row
                while (dataReader.Read())
                {
                    try
                    {
                        string newJobID = dataReader["JobID"].ToString();
                        jobsToBuild.Add(newJobID);
                    }
                    catch (Exception q)
                    {

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

                //we use this seperate list rather than add the jobs inside the above loop because the job has to "load" itself as well
                //this means that job is opening up a database connection, and we would get an error for having multiple connections
                foreach(string s in jobsToBuild)
                {
                    Job newJob = new Job(s, "load");
                    associatedJobs.Add(newJob);
                }
            }
            #endregion

            #region Job Runs
            db = new DBConnection();
            //the query to run
            cmdString = "SELECT RunID, JobID FROM job_run WHERE PO_No = '" + PO_No + "'";

            //open the connection and execute our query
            if (db.OpenConnection())
            {
                MySqlCommand cmd = new MySqlCommand(cmdString, db.getConnection());
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //grab the fields from the row
                while (dataReader.Read())
                {
                    try
                    {
                        //use the struct
                        runInfo newrun;
                        newrun.jobid = dataReader["JobID"].ToString();
                        newrun.runid = Convert.ToInt32(dataReader["RunID"].ToString());
                        runsToBuild.Add(newrun);
                    }
                    catch (Exception q)
                    {

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

                //we use this seperate list rather than add the jobs inside the above loop because the job has to "load" itself as well
                //this means that job is opening up a database connection, and we would get an error for having multiple connections
                if (runsToBuild.Count > 0)
                {
                    foreach (runInfo s in runsToBuild)
                    {
                        JobRun newjobrun = new JobRun(PO_No, s.jobid, s.runid, "load");
                        jobRuns.Add(newjobrun);
                    }
                }
            }
            #endregion


        }