コード例 #1
0
ファイル: ViewPO.cs プロジェクト: stamlercas/acutwist
        private void btnCreateJobRun_Click(object sender, EventArgs e)
        {
            int runid = 0;
            try
            {
                string targetjob = listJobs.SelectedItem.ToString();

                JobRun jr = new JobRun(po.PO_No, targetjob);
                jr.DueDate = dateRunDueDate.Value;
                jr.ShipDate = dateRunShipDate.Value;
                jr.OrderQty = Convert.ToInt32(txtRunOrderQty.Text);
                jr.MakeQty = Convert.ToInt32(txtRunMakeQty.Text);
                jr.Upload();
                //upload what's placed in the jqcalendar on the insert trigger into 
                //google calendar
                string subject = "Ship: " + jr.PO_No + "-" + jr.JobID + "-" + jr.RunID;
                TimeSpan tsStart = new TimeSpan(0, 0, 0);
                TimeSpan tsEnd = new TimeSpan(23, 59, 59);
                DateTime dueDate = Convert.ToDateTime(jr.DueDate.ToString("yyyy-MM-dd"));
                DateTime shipDate = Convert.ToDateTime(jr.ShipDate.ToString("yyyy-MM-dd")) + tsEnd;
                new GoogleCalendar().createEvent(subject, dueDate, shipDate);
                //new GoogleCalendar().createEvent("Test From AcuTwist", new DateTime(2016, 3, 3, 10, 30, 0),
                //    new DateTime(2016, 3, 3, 10, 30, 0));

                //add the run to the po
                po.jobRuns.Add(jr);
                //add it to the viewpo list
                listJobRuns.Items.Add("" + jr.RunID + ", " + jr.JobID + ", " + jr.ShipDate.ToString("MM-dd-yyyy"));
                dateRunDueDate.Value = DateTime.Now;
                dateRunShipDate.Value = DateTime.Now;
                txtRunMakeQty.Text = "";
                txtRunOrderQty.Text = "";

                
             }
            catch (Exception q)
            {

            }

        }
コード例 #2
0
ファイル: ViewPO.cs プロジェクト: stamlercas/acutwist
        private void btnDeleteRun_Click(object sender, EventArgs e)
        {
            try
            {
                string[] rundisplay = listJobRuns.SelectedItem.ToString().Split(',');
                string targetrun = rundisplay[0];
                string runjob = rundisplay[1].Substring(1);
                int targetrunid = Convert.ToInt32(targetrun);
                JobRun victim = new JobRun(po.PO_No, runjob, targetrunid, "load");

                DBConnection conn = new DBConnection();
                if (conn.OpenConnection())
                {
                    MySqlCommand command = conn.getConnection().CreateCommand();
                    command.CommandText = "DELETE FROM job_run WHERE PO_No = '" + victim.PO_No + "' AND JobID = '" + victim.JobID + "' AND RunID = " + victim.RunID ;

                    command.ExecuteNonQuery();
                }

                conn.CloseConnection();

                po.jobRuns.Remove(victim);
                listJobRuns.Items.Remove(listJobRuns.SelectedItem);
            }
            catch (Exception q)
            { }
        }
コード例 #3
0
ファイル: PO.cs プロジェクト: stamlercas/acutwist
        //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


        }