コード例 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (!IsEmptyOrWhiteSpace(textBoxName.Text))
     {
         try
         {
             if (!(DatabaseConnection.getInstance().GetSelectRowsCount(string.Format("SELECT * FROM Task WHERE Title='{0}' AND Id<>{1}", textBoxName.Text, Id)) > 0))
             {
                 DatabaseConnection.getInstance().ExecuteQuery(string.Format("UPDATE Task SET Title='{0}' WHERE Id='{1}'", textBoxName.Text, Id));
                 MessageBox.Show("Task Title upated!");
                 frm.reload();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Task with same name already exist!");
             }
         }
         catch (Exception exp)
         {
             MessageBox.Show("Failed to update Task, Error : " + exp);
         }
     }
     else
     {
         MessageBox.Show("Task name must not be empty or white spaces!");
     }
 }
コード例 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         DatabaseConnection.getInstance().ExecuteQuery(string.Format("DELETE FROM Task WHERE Id='{0}'", Id));
         MessageBox.Show("Task Deleted!");
         frm.reload();
         this.Close();
     }
     catch (Exception exp)
     {
         MessageBox.Show("Failed to delete task, Error : " + exp);
     }
 }