Beispiel #1
0
 private void ViewScheduleButton_Click(object sender, EventArgs e)
 {
     
     String GivenDay = SelectDay.Text.Trim().Substring(0,11);
     BLL.Task task= new BLL.Task();
     DataTable GeTGivenDay = task.GetTaskList("BeginTime like '%" + GivenDay+"%'");
     dg_dayview.DataSource = GeTGivenDay;
 }
Beispiel #2
0
        public void TasksUpdate(BLL.Task updatetask)
        {
            SqlConnection conn = null;

            try
            {
                // prepare connection to the database.
                conn = SQLHelper.GetConnection();
                conn.Open();
                if (conn == null)
                {
                    throw new Exception("Sorry, connection to the database failed.");
                }

                // write sqlcommand.
                string     storedProcedureName = "TaskUpdates";
                SqlCommand cmd = new SqlCommand();
                cmd.Connection     = conn;
                cmd.CommandTimeout = 50000;
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandText    = storedProcedureName;

                cmd.Parameters.AddWithValue("@TaskId", updatetask.TaskId);
                cmd.Parameters.AddWithValue("@ProjectId", updatetask.ProjectId);
                cmd.Parameters.AddWithValue("@SkillId", updatetask.SkillId);
                cmd.Parameters.AddWithValue("@TaskDate", updatetask.TaskDate);
                cmd.Parameters.AddWithValue("@Title", updatetask.Title);
                cmd.Parameters.AddWithValue("@Details", updatetask.Details);
                cmd.Parameters.AddWithValue("@TimeInMinutes", updatetask.TimeInMinutes);
                //cmd.Parameters.AddWithValue("@CreatedOnUTC", updatetask.CreatedOnUTC);
                cmd.Parameters.AddWithValue("@UpdatedOnUTC", updatetask.UpdatedOnUTC);
                //  cmd.Parameters.AddWithValue("@IpUsed", updatetask.IpUsed);
                //cmd.Parameters.AddWithValue("@UserId", updatetask.UserId);

                int success = cmd.ExecuteNonQuery();
                //return true; // success
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Beispiel #3
0
        public BLL.Task TasksDelete(long taskid)
        {
            BLL.Task      tasks  = new BLL.Task();
            SqlConnection conn   = null;
            SqlDataReader reader = null;

            try
            {
                // prepare connection to the database.
                conn = SQLHelper.GetConnection();
                conn.Open();
                if (conn == null)
                {
                    throw new Exception("Sorry, connection to the database failed.");
                }

                // write sqlcommand.
                string     storedProcedureName = "TasksDelete";
                SqlCommand cmd = new SqlCommand();
                cmd.Connection     = conn;
                cmd.CommandTimeout = 50000;
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandText    = storedProcedureName;

                cmd.Parameters.AddWithValue("@TaskId", taskid);
                int sc = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Dispose();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(tasks);
        }
Beispiel #4
0
        private void scheduleUI_Load(object sender, EventArgs e)
        {
            taskPriorityListbox.Items.Add("一般");
            taskPriorityListbox.Items.Add("重要");
            taskPriorityListbox.Items.Add("非常重要");

            yearcomboBox.Items.Add("2014");
            yearcomboBox.Items.Add("2015");
            yearcomboBox.Items.Add("2016");

            monthcomboBox.Items.Add("10");
            monthcomboBox.Items.Add("11");
            monthcomboBox.Items.Add("12");


            taskTypeListbox.Items.Add("约会");
            taskTypeListbox.Items.Add("会议");
            taskTypeListbox.Items.Add("作息");
            taskTypeListbox.Items.Add("生日");
            taskTypeListbox.Items.Add("备忘");

           //未完成事项
            BLL.Task lefttask = new BLL.Task();
            DataTable GeTleftDay = lefttask.GetTaskList(" Finished = 0 ");
            dataGridView1.DataSource = GeTleftDay;

            dateTimePickerremind.CustomFormat = "yyyy年MM月dd日 HH:mm:ss ";
            dateTimePickerremind.Format = System.Windows.Forms.DateTimePickerFormat.Custom;


            taskDateTimeSetupBox.CustomFormat = "yyyy年MM月dd日 HH:mm:ss ";
            taskDateTimeSetupBox.Value = DateTime.Now;
            taskDateTimeSetupBox.Format = System.Windows.Forms.DateTimePickerFormat.Custom;

            
            

            
        }
Beispiel #5
0
        public BLL.Task TasksLoadByTaskId(long taskid)
        {
            BLL.Task      tasks  = new BLL.Task();
            SqlConnection conn   = null;
            SqlDataReader reader = null;

            try
            {
                // prepare connection to the database.
                conn = SQLHelper.GetConnection();
                conn.Open();
                if (conn == null)
                {
                    throw new Exception("Sorry, connection to the database failed.");
                }

                // write sqlcommand.
                string     storedProcedureName = "TasksLoadByTaskId";
                SqlCommand cmd = new SqlCommand();
                cmd.Connection     = conn;
                cmd.CommandTimeout = 50000;
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandText    = storedProcedureName;

                cmd.Parameters.AddWithValue("@TaskId", taskid);
                reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    tasks = new BLL.Task
                    {
                        TaskId        = (long)reader["TaskId"],
                        ProjectId     = (long)reader["ProjectId"],
                        SkillId       = (long)reader["SkillId"],
                        TaskDate      = Convert.ToDateTime(reader["TaskDate"]),
                        Title         = Convert.ToString(reader["Title"]),
                        Details       = Convert.ToString(reader["Details"]),
                        TimeInMinutes = Convert.ToInt32(reader["TimeInMinutes"]),
                        CreatedOnUTC  = Convert.ToDateTime(reader["CreatedOnUTC"]),
                        UpdatedOnUTC  = Convert.ToDateTime(reader["UpdatedOnUTC"]),
                        IpUsed        = Convert.ToString(reader["IpUsed"]),
                        UserId        = Convert.ToString(reader["UserId"]),
                    };
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Dispose();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(tasks);
        }
Beispiel #6
0
        public List <BLL.Task> GetAllTask()
        {
            List <BLL.Task> tasks   = new List <BLL.Task>();
            SqlConnection   conn    = null;
            SqlDataAdapter  adapter = null;

            try
            {
                // prepare connection to the database.
                conn = SQLHelper.GetConnection();
                conn.Open();

                if (conn == null)
                {
                    throw new Exception("Sorry, connection to the database failed.");
                }

                // write sqlcommand.
                string     storedProcedureName = "TasksLoadAll";
                SqlCommand cmd = new SqlCommand();
                cmd.Connection     = conn;
                cmd.CommandTimeout = 50000;
                cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                cmd.CommandText    = storedProcedureName;

                //Prepare and Attach parameters here. (just sample)
                //SqlParameter param1 = new SqlParameter("@FirstName", "");
                //cmd.Parameters.Add(param1);

                // fetch data from database.
                DataSet dsData = new DataSet();
                adapter = new SqlDataAdapter(cmd);
                adapter.Fill(dsData);

                // iterate all the fetched data and populate students objects.
                if (dsData != null)
                {
                    if (dsData.Tables.Count > 0)
                    {
                        foreach (DataRow dr in dsData.Tables[0].Rows)
                        {
                            BLL.Task task = new BLL.Task
                            {
                                TaskId        = (long)dr["TaskId"],
                                ProjectId     = (long)dr["ProjectId"],
                                SkillId       = (long)dr["SkillId"],
                                TaskDate      = Convert.ToDateTime(dr["TaskDate"]),
                                Title         = Convert.ToString(dr["Title"]),
                                Details       = Convert.ToString(dr["Details"]),
                                TimeInMinutes = Convert.ToInt32(dr["TimeInMinutes"]),
                                CreatedOnUTC  = Convert.ToDateTime(dr["CreatedOnUTC"]),
                                UpdatedOnUTC  = Convert.ToDateTime(dr["UpdatedOnUTC"]),
                                IpUsed        = Convert.ToString(dr["IpUsed"]),
                                UserId        = Convert.ToString(dr["UserId"]),
                            };
                            tasks.Add(task);
                        }
                    }
                }
                // return skills list.
                return(tasks);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (adapter != null)
                {
                    adapter.Dispose();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Beispiel #7
0
        private void OK_Click(object sender, EventArgs e)
        {
            if (taskTitleBox.Text == "")
            {
                MessageBox.Show("日程标题不能为空!", "Error");
                return;
            }
            if (taskDetailBox.Text == "")
            {
                MessageBox.Show("日程内容不能为空!", "Error");
                return;
            }

            if (taskTypeListbox.SelectedIndex == -1)
            {
                MessageBox.Show("请指定日程类型!", "Error");
                return;
            }

            if (taskPriorityListbox.SelectedIndex == -1)
            {
                MessageBox.Show("请指定优先度!", "Error");
                return;
            }

            DateTime BeginTime = DateTime.Parse(taskDateTimeSetupBox.Text.Trim());			
            if (BeginTime < DateTime.Now)
            {
                MessageBox.Show("日程开始时间已过!", "Error");
                return;
            }
            string title = taskTitleBox.Text.Trim();
            string detail = taskDetailBox.Text.Trim();
            string type = taskTypeListbox.Text.Trim();
            string prio = taskPriorityListbox.Text.Trim();
            string begintime = taskDateTimeSetupBox.Text.Trim();
            string notifytime = dateTimePickerremind.Text.Trim();
          

            Model.Task insecttask = new Model.Task();
            insecttask.Title = title;
            insecttask.Detail = detail;
            insecttask.Type = type;
            insecttask.Priority = prio;
            insecttask.BeginTime = begintime;
            insecttask.NotifyTime = notifytime;
            insecttask.Finished = 0;

            BLL.Task inttask = new BLL.Task();
            if (inttask.AddTaskList(insecttask))
            {
                MessageBox.Show("日程添加成功!");
                taskTitleBox.Text = "";
                taskDetailBox.Text = "";
                taskDateTimeSetupBox.Value = DateTime.Now;
                taskPriorityListbox.Text = " ";
                taskTypeListbox.Text = " ";
                dateTimePickerremind.Value = DateTime.Now;
                
            }
            else
            {
                MessageBox.Show("很抱歉!日程添加失败!");
            }

        }
Beispiel #8
0
 public void reload()
 {
     BLL.Task lefttask = new BLL.Task();
     DataTable GeTleftDay = lefttask.GetTaskList(" Finished = 0 ");
     dataGridView1.DataSource = GeTleftDay;
 }
Beispiel #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            string year = yearcomboBox.Text.Trim();
            string month = monthcomboBox.Text.Trim();
            string GiveMonth = year + "年" + month + "月";
            BLL.Task montask = new BLL.Task();
            DataTable GeTGivenDay = montask.GetTaskList("BeginTime like '%" + GiveMonth + "%'");
            monthdataGridView.DataSource = GeTGivenDay;

        }