Exemplo n.º 1
0
 private void step1_DoubleClick(object sender, EventArgs e)
 {
     if (customer.Equals("HONDA AERO"))
     {
         Form hondaPo = new HondaPOReview(jobNo, true, int.Parse(workflowListBox.SelectedItem.ToString()));
         hondaPo.ShowDialog();
     }
     else if (customer.Equals("ROLLS"))
     {
         Form rollsPO = new RollsRoycePOReview(jobNo, true);
         rollsPO.ShowDialog();
     }
 }
Exemplo n.º 2
0
        // submits a new workflow to the db with no
        private void createWorkflowButton_Click(object sender, EventArgs e)
        {
            string type = string.Empty;

            if (customer.Equals("HONDA AERO"))
            {
                int next_ID = 0;
                using (OdbcConnection conn = new OdbcConnection(Globals.odbc_connection_string))
                {
                    conn.Open();

                    // first get next Worflow ID
                    string query =
                        "SELECT MAX(Workflow_ID)\n" +
                        "FROM ATI_Workflow.dbo.StatusData\n" +
                        "WHERE Job = '" + jobNo + "';";

                    OdbcCommand    comm   = new OdbcCommand(query, conn);
                    OdbcDataReader reader = comm.ExecuteReader();

                    // check if you can load one row
                    if (reader.Read() && !reader.IsDBNull(0))
                    {
                        // increase the workflow ID by 1
                        next_ID = reader.GetInt32(0) + 1;
                    }
                }
                HondaPOReview poReview = new HondaPOReview(jobNo, false, next_ID);
                poReview.ShowDialog();
                type = poReview.type;
            }
            else if (customer.Equals("ROLLS"))
            {
                RollsRoycePOReview poReview = new RollsRoycePOReview(jobNo, false);
                poReview.ShowDialog();
                type = poReview.type;
            }

            // in case form was closed prematurely
            if (type.Equals("Invalid"))
            {
                return;
            }

            // submit an insert query
            using (OdbcConnection conn = new OdbcConnection(Globals.odbc_connection_string))
            {
                conn.Open();

                // first get next Worflow ID
                string query =
                    "SELECT MAX(Workflow_ID)\n" +
                    "FROM ATI_Workflow.dbo.StatusData\n" +
                    "WHERE Job = '" + jobNo + "';";

                OdbcCommand    comm   = new OdbcCommand(query, conn);
                OdbcDataReader reader = comm.ExecuteReader();

                // check if you can load one row
                if (reader.Read() && !reader.IsDBNull(0))
                {
                    // increase the workflow ID by 1
                    int next_ID = reader.GetInt32(0) + 1;

                    query =
                        "INSERT INTO [ATI_Workflow].[dbo].[StatusData]\n" +
                        "([Job]\n" +
                        ",[Workflow_ID]\n" +
                        ",[Type]\n" +
                        ",[LastUpdated]\n" +
                        ",[POReview_Status]\n" +
                        ",[POReview_UserName]\n" +
                        ",[POReview_TimeStamp])\n" +
                        "VALUES\n" +
                        "('" + jobNo + "',\n" +
                        next_ID + ",\n" +
                        "'" + type + "',\n" +
                        "'" + DateTime.Now + "',\n" +
                        "'Complete',\n" +
                        "'" + Globals.userName + "',\n" +
                        "'" + DateTime.Now + "');";

                    comm = new OdbcCommand(query, conn);
                    int rows = comm.ExecuteNonQuery();

                    // check data was submitted succesfully
                    if (rows != 1)
                    {
                        MessageBox.Show("Data submitted was invaldi");
                        return;
                    }

                    // add new workflow to list and select
                    workflowListBox.Items.Add(next_ID);
                    workflowListBox.SelectedIndex = workflowListBox.FindString(next_ID.ToString());
                }
                else
                {
                    MessageBox.Show(Globals.generic_IT_error);
                }
            }
        }