예제 #1
0
 private void ClearFields()
 {
     addNew                  = true;
     UserIdLabel.Text        = "";
     CreateDate.Text         = DateTime.Now.ToString();
     LastModified.Text       = DateTime.Now.ToString();
     comboBox1.SelectedIndex = GetImportance.FromString("Moderate");
     descriptions.Text       = "";
     button1.Text            = "Add New";
 }
예제 #2
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         addNew                  = false;
         UserIdLabel.Text        = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
         CreateDate.Text         = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
         LastModified.Text       = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
         comboBox1.SelectedIndex = GetImportance.FromString(dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString());
         descriptions.Text       = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
         button1.Text            = "Update";
     }
     catch (ArgumentOutOfRangeException)
     {
     }
 }
예제 #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (addNew)
     {
         // add new event
         DialogResult dr;
         dr = MessageBox.Show("Do you really want to add new Event?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (dr == DialogResult.Yes)
         {
             if (AddEvent(descriptions.Text, GetImportance.FromString(comboBox1.SelectedItem.ToString())) == 1)
             {
                 //success
                 dataGridView1.DataSource = GetAllEvents(UserId);
                 ClearFields();
                 MessageBox.Show("Successfully Added Event", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
             else
             {
                 //failed
                 MessageBox.Show("Failed to Add Event", "Something went wrong", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         //update event
         DialogResult dr;
         dr = MessageBox.Show("Do you really want to update the Event?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (dr == DialogResult.Yes)
         {
             if (UpdateEvent(Convert.ToInt32(UserIdLabel.Text), CreateDate.Text, descriptions.Text, GetImportance.FromString(comboBox1.Text)) == 1)
             {
                 //success
                 dataGridView1.DataSource = GetAllEvents(UserId);
                 ClearFields();
                 MessageBox.Show("Successfully updated user", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
             else
             {
                 //failed
                 MessageBox.Show("Failed to update", "Something went wrong", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }