コード例 #1
0
        //Create Task
        private void TaskCreate()
        {
            try
            {
                DBHelper dbh = new DBHelper();
                if (task.Text.Equals("") || taskDetails.Text.Equals("") || taskStarts.Text.Equals("") || taskDeadline.Text.Equals(""))
                {
                    Toast.MakeText(this, "Fill in all fields!", ToastLength.Long).Show();
                }
                else
                {
                    if (DateTime.Parse(taskDeadline.Text) <= DateTime.Parse(taskStarts.Text))
                    {
                        Toast.MakeText(this, "Task deadline should be greater than task start!", ToastLength.Long).Show();
                        return;
                    }
                    else if (DateTime.Parse(taskDeadline.Text) <= DateTime.Today)
                    {
                        Toast.MakeText(this, "Task deadline should be greater than current date!", ToastLength.Long).Show();
                    }
                    else
                    {
                        int mproject;

                        if (selProjectId <= 0)
                        {
                            allprojects = ProjectsCollection.GetProjects();
                            mproject    = Convert.ToInt32(allprojects[project.SelectedItemPosition].Id);
                        }
                        else
                        {
                            mproject = selProjectId;
                        }

                        string  mtask         = DatabaseUtils.SqlEscapeString(task.Text);
                        string  mtaskDesc     = DatabaseUtils.SqlEscapeString(taskDetails.Text);
                        string  mtaskStart    = taskStarts.Text;
                        string  mtaskDeadline = taskDeadline.Text;
                        decimal mtaskBudget   = Convert.ToDecimal(taskBudget.Text);

                        string result = dbh.CreateProjectTask(mtask, mproject, mtaskDesc, mtaskStart, mtaskDeadline, mtaskBudget);

                        if (result.Equals("ok"))
                        {
                            Toast.MakeText(this, "Project task added!", ToastLength.Short).Show();
                            Finish();
                        }
                        else
                        {
                            Toast.MakeText(this, "Failed adding project task\n. Error info:" + result, ToastLength.Short).Show();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Error:\n" + ex.Message, ToastLength.Long);
            }
        }
コード例 #2
0
 //populate list
 private void populateProjectList(View view)
 {
     projects = ProjectsCollection.GetProjects();
     adapter  = new ProjectsAdapter(view.Context, projects);
     mListProjects.Adapter = adapter;
 }