private void button1_Click(object sender, EventArgs e)
 {
     if (!IsEmptyOrWhiteSpace(textBoxName.Text))
     {
         if (!IsEmptyOrWhiteSpace(textBoxEmail.Text))
         {
             try
             {
                 if (!(DatabaseConnection.getInstance().GetSelectRowsCount(string.Format("SELECT * FROM Comity WHERE Name='{0}'", textBoxName.Text)) > 0))
                 {
                     DatabaseConnection.getInstance().ExecuteQuery(string.Format("INSERT INTO Comity(Name,Email,Status) VALUES ('{0}','{1}',1)", textBoxName.Text, textBoxEmail.Text));
                     var           data = DatabaseConnection.getInstance().getData("SELECT Comity.Id,Comity.Name AS Name,LookUp.Name AS Status,Email FROM Comity JOIN LookUp on LookUp.Id=Comity.Status ORDER BY Comity.Name");
                     BindingSource src  = new BindingSource();
                     src.DataSource = data;
                     dataGridViewComities.DataSource         = src;
                     dataGridViewComities.Columns[2].Visible = false;
                     MessageBox.Show("Committee Added!");
                     textBoxName.Text = "";
                 }
                 else
                 {
                     MessageBox.Show("Committee with same name already exist!");
                 }
             }
             catch (Exception exp)
             {
                 MessageBox.Show("Failed to add committee, Error : " + exp);
             }
         }
         else
         {
             MessageBox.Show("Mail field must not empty");
         }
     }
     else
     {
         MessageBox.Show("Committee Name must not be empty!");
     }
 }
Example #2
0
        private void comboBoxStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.Text != "")
            {
                var tasks = DatabaseConnection.getInstance().getData(string.Format("SELECT Task.Id,Comity.Name,Task.Title,LookUp.Name,StartDate,EndDate FROM Comity JOIN Task on Task.ComityId=Comity.Id JOIN LookUp on LookUp.Id=Task.Status WHERE Task.Status<>'7' AND Comity.Name='{0}' AND LookUp.Name='{1}'  order by LookUp.Name", comboBox1.Text, comboBoxStatus.Text));
                List <TaskMonitor> list = new List <TaskMonitor>();
                while (tasks.Read())
                {
                    list.Add(new TaskMonitor()
                    {
                        Id        = tasks.GetInt32(0),
                        Committee = tasks.GetString(1),
                        Task      = tasks.GetString(2),
                        Status    = tasks.GetString(3),
                        StartDate = Convert.ToDateTime(tasks.GetString(4)),
                        EndDate   = Convert.ToDateTime(tasks.GetString(5)),
                    });
                }

                BindingSource src = new BindingSource();
                src.DataSource                   = list;
                dataGridView1.DataSource         = src;
                dataGridView1.Columns[1].Visible = false;

                foreach (DataGridViewRow Myrow in dataGridView1.Rows)
                {
                    if (Myrow.Cells[4].Value.ToString() == "Completed")
                    {
                        dataGridView1.Rows[Myrow.Index].Cells[4].Style.BackColor = Color.LightGreen;
                    }
                    else if (Myrow.Cells[4].Value.ToString() == "Expired")
                    {
                        dataGridView1.Rows[Myrow.Index].Cells[4].Style.BackColor = Color.IndianRed;
                    }
                    else if (Myrow.Cells[4].Value.ToString() == "Extended")
                    {
                        dataGridView1.Rows[Myrow.Index].Cells[4].Style.BackColor = Color.Orange;
                    }
                    else if (Myrow.Cells[4].Value.ToString() == "InProgress")
                    {
                        dataGridView1.Rows[Myrow.Index].Cells[4].Style.BackColor = Color.LightBlue;
                    }
                }
            }
            else
            {
                var tasks = DatabaseConnection.getInstance().getData(string.Format("SELECT Task.Id,Comity.Name,Task.Title,LookUp.Name,StartDate,EndDate FROM Comity JOIN Task on Task.ComityId=Comity.Id JOIN LookUp on LookUp.Id=Task.Status WHERE Task.Status<>'7' AND LookUp.Name='{0}' order by LookUp.Name", comboBoxStatus.Text));
                List <TaskMonitor> list = new List <TaskMonitor>();
                while (tasks.Read())
                {
                    list.Add(new TaskMonitor()
                    {
                        Id        = tasks.GetInt32(0),
                        Committee = tasks.GetString(1),
                        Task      = tasks.GetString(2),
                        Status    = tasks.GetString(3),
                        StartDate = Convert.ToDateTime(tasks.GetString(4)),
                        EndDate   = Convert.ToDateTime(tasks.GetString(5)),
                    });
                }

                BindingSource src = new BindingSource();
                src.DataSource                   = list;
                dataGridView1.DataSource         = src;
                dataGridView1.Columns[1].Visible = false;

                foreach (DataGridViewRow Myrow in dataGridView1.Rows)
                {
                    if (Myrow.Cells[4].Value.ToString() == "Completed")
                    {
                        dataGridView1.Rows[Myrow.Index].Cells[4].Style.BackColor = Color.LightGreen;
                    }
                    else if (Myrow.Cells[4].Value.ToString() == "Expired")
                    {
                        dataGridView1.Rows[Myrow.Index].Cells[4].Style.BackColor = Color.IndianRed;
                    }
                    else if (Myrow.Cells[4].Value.ToString() == "Extended")
                    {
                        dataGridView1.Rows[Myrow.Index].Cells[4].Style.BackColor = Color.Orange;
                    }
                    else if (Myrow.Cells[4].Value.ToString() == "InProgress")
                    {
                        dataGridView1.Rows[Myrow.Index].Cells[4].Style.BackColor = Color.LightBlue;
                    }
                }
            }
        }
Example #3
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!");
            }
        }