Пример #1
0
 private void AddData()
 {
     try
     {
         m_Log.Trace("AddData({0})", textBoxShow.Text);
         using (TodoListEntities context = new TodoListEntities())
         {
             TodoList todoList = new TodoList();
             {
                 todoList.Name     = textBoxShow.Text;
                 todoList.TodoDate = Convert.ToDateTime(dateTimePickerDate.Text);
                 // TODO: dodac obsluge godziny
                 //TodoDate = Convert.ToDateTime(string.Format("{0} {1}", dateTimePickerDate.Text, dateTimePickerTime.Text)),
                 todoList.Descpription = richTextBoxRecipes.Text;
             };
             m_Log.Trace("AddData({0})", todoList);
             context.TodoLists.Add(todoList);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         m_Log.Error(ex);
     }
 }
Пример #2
0
 private void DeleteData()
 {
     m_Log.Trace("DeleteData({0})", FormInfo.TextBoxShowValue);
     using (TodoListEntities contextt = new TodoListEntities())
     {
         TodoList todoList = contextt.TodoLists.FirstOrDefault(r => r.Name == FormInfo.TextBoxShowValue);
         if (todoList != null)
         {
             contextt.TodoLists.Remove(todoList);
             contextt.SaveChanges();
         }
     }
 }
Пример #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            m_Log.Trace("Form1_Load()");

            using (TodoListEntities context = new TodoListEntities())
            {
                m_Log.Trace("App Connection string: {0}", context.Database.Connection.ConnectionString);
            }

            SelectData();
            groupBox1.Visible = true;
            // TODO: dodac obsluge godziny
            dateTimePickerTime.Visible = false;
        }
Пример #4
0
 private void EditData()
 {
     m_Log.Trace("EditData()");
     using (TodoListEntities contextt = new TodoListEntities())
     {
         TodoList todoList = contextt.TodoLists.FirstOrDefault(r => r.Name == FormInfo.TextBoxShowValue);
         if (todoList != null)
         {
             todoList.Name         = textBoxShow.Text;
             todoList.TodoDate     = Convert.ToDateTime(dateTimePickerDate.Text);
             todoList.Descpription = richTextBoxRecipes.Text;
         }
         contextt.SaveChanges();
     }
 }
Пример #5
0
        //private void dateTimePickerFilter_ValueChanged(object sender, EventArgs e)
        //{
        //    m_Log.Trace("dateTimePickerFilter_ValueChanged()");

        //    labelTodoItemsDate.Text = dateTimePickerFilter.Text;

        //    DataTable dt = new DataTable();
        //    SqlConnection conn = new SqlConnection();
        //    conn.ConnectionString =
        //        ConfigurationManager.ConnectionStrings[FormInfo.ConnectionStringName]
        //            .ConnectionString;

        //    DateTime dateTimePickerFilterDate = Convert.ToDateTime(dateTimePickerFilter.Text);

        //    try
        //    {
        //        conn.Open();
        //        SqlCommand myCmd = new SqlCommand("SelectTodo", conn);
        //        myCmd.CommandType = CommandType.StoredProcedure;
        //        //myCmd.Parameters.AddWithValue("@TodoDate", "%" + dateTimePickerFilterDate.ToString(FormInfo.DateFormatDate) + "%");
        //        //myCmd.Parameters.Add("@TodoDate", SqlDbType.NVarChar).Value = "%" + dateTimePickerFilterDate.ToString(FormInfo.DateFormatDate) + "%";
        //        myCmd.Parameters.Add("@TodoDate", SqlDbType.NVarChar).Value = dateTimePickerFilterDate.ToString(FormInfo.DateFormatDate);
        //        m_Log.Trace("dateTimePickerFilterDate.ToString(FormInfo.DateFormatDate): {0}", dateTimePickerFilterDate.ToString(FormInfo.DateFormatDate));
        //        SqlDataAdapter da = new SqlDataAdapter(myCmd);
        //        da.Fill(dt);
        //        dataGridViewRecipes.DataSource = dt;
        //    }
        //    catch (Exception ex)
        //    {
        //        m_Log.Error(ex);
        //    }
        //    finally
        //    {
        //        conn.Close();
        //    }
        //}
        private void dateTimePickerFilter_ValueChanged(object sender, EventArgs e)
        {
            m_Log.Trace("dateTimePickerFilter_ValueChanged()");

            labelTodoItemsDate.Text = dateTimePickerFilter.Text;

            {
                try
                {
                    DateTime dt = Convert.ToDateTime(dateTimePickerFilter.Text);
                    using (TodoListEntities contextt = new TodoListEntities())
                    {
                        var todoList = contextt.TodoLists
                                       .Where(t => t.TodoDate == dt).ToArray();
                        dataGridViewRecipes.DataSource = todoList;
                    }
                }
                catch (Exception ex)
                {
                    m_Log.Error(ex);
                }
            }
        }
Пример #6
0
        private void SelectData()
        {
            m_Log.Trace("SelectData() - ladowanie contentu do tabeli...");

            labelFilterDate.Text    = Resources.txtTimeItemsFrom;
            labelTodoItemsDate.Text = Resources.txtAllTimeItems;

            try
            {
                using (TodoListEntities contextt = new TodoListEntities())
                {
                    var todoList = (from b in contextt.TodoLists
                                    orderby b.TodoDate descending
                                    select b).ToArray();

                    dataGridViewRecipes.DataSource = todoList;
                }
            }
            catch (Exception ex)
            {
                m_Log.Error(ex);
                MessageBox.Show(string.Format("{0}", ex));
            }
        }