Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text != "")
            {
                long status = 0;
                if (comboBox1.Text == "InProgress")
                {
                    status           = 3;
                    labelStatus.Text = "InProgress";
                }

                if (comboBox1.Text == "Completed")
                {
                    status           = 4;
                    labelStatus.Text = "Completed";
                }

                if (comboBox1.Text == "Expired")
                {
                    status           = 5;
                    labelStatus.Text = "Expired";
                }

                if (comboBox1.Text == "Extended")
                {
                    status           = 6;
                    labelStatus.Text = "Extended";
                }

                try
                {
                    if (comboBox1.Text == "Extended")
                    {
                        DatabaseConnection.getInstance().ExecuteQuery(string.Format("UPDATE Task SET Status='{0}',EndDate='{1}' WHERE Id='{2}'", status, Convert.ToDateTime(dateTimePickerEndDate.Value), Id));
                        if (labelStatus.Text == "Completed")
                        {
                            labelStatus.ForeColor = System.Drawing.Color.Green;
                        }
                        if (labelStatus.Text == "Extended")
                        {
                            labelStatus.ForeColor = System.Drawing.Color.Orange;
                        }
                        if (labelStatus.Text == "Expired")
                        {
                            labelStatus.ForeColor = Color.Red;
                        }
                        if (labelStatus.Text == "InProgress")
                        {
                            labelStatus.ForeColor = Color.Blue;
                        }
                        MessageBox.Show("Status Update");
                        frm.update();
                    }
                    else
                    {
                        DatabaseConnection.getInstance().ExecuteQuery(string.Format("UPDATE Task SET Status='{0}' WHERE Id='{1}'", status, Id));
                        if (labelStatus.Text == "Completed")
                        {
                            labelStatus.ForeColor = System.Drawing.Color.Green;
                        }
                        if (labelStatus.Text == "Extended")
                        {
                            labelStatus.ForeColor = System.Drawing.Color.Orange;
                        }
                        if (labelStatus.Text == "Expired")
                        {
                            labelStatus.ForeColor = Color.Red;
                        }
                        if (labelStatus.Text == "InProgress")
                        {
                            labelStatus.ForeColor = Color.Blue;
                        }
                        MessageBox.Show("Status Update");
                        frm.update();
                    }
                }catch (Exception exp)
                {
                    MessageBox.Show("Failed to Update Task, Error : " + exp);
                }
            }
            else
            {
                MessageBox.Show("Status must be selected!");
            }
        }