Ejemplo n.º 1
0
        // save to dataBase


        private void btnAddReminder_Click(object sender, RoutedEventArgs e)
        {
            NewReminderWindow newReminder = new NewReminderWindow();

            if (newReminder.ShowDialog() == true)
            {
                // insert new reminder into table
                Reminder r       = newReminder.newReminder;
                string   command = @"insert into Reminders(Name,LongDescription,DueDate) Values(" +
                                   @"'" + r.ShortDes + @"','" +
                                   r.LongDes + @"','" + r.DueDate + @"')";
                try {
                    using (SqlConnection con = new SqlConnection(connectionDB))
                    {
                        SqlCommand     cmd = new SqlCommand(command, con);
                        SqlDataAdapter sda = new SqlDataAdapter(cmd);
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        listShortDescription.Items.Clear();
                        PopulateListView();
                        listShortDescription.Items.Refresh();
                    }
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        //private void btnUpdate_Click(object sender, RoutedEventArgs e)
        //{
        //    PopupNotifier notifiy = new PopupNotifier();
        //    notifiy.TitleText = listShortDescription.SelectedItem.ToString();
        //    notifiy.Popup();


        //}

        private void btnUpdate_Click_1(object sender, RoutedEventArgs e)
        {
            string getLong = listShortDescription.SelectedItem.ToString();



            string  command = @"select * from Reminders where Name = '" + getLong + "' ";
            DataSet sd      = new DataSet();

            using (SqlConnection con = new SqlConnection(connectionDB))
            {
                SqlCommand     cmd = new SqlCommand(command, con);
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(sd, "short");

                Reminder r = new Reminder();
                foreach (DataRow data in sd.Tables["short"].Rows)
                {
                    r.ShortDes = data["Name"].ToString();
                    r.LongDes  = data["LongDescription"].ToString();
                    r.DueDate  = DateTime.Parse(data["DueDate"].ToString());
                }

                NewReminderWindow ModifiedReminder = new NewReminderWindow(r);
                ModifiedReminder.ShowDialog();
                //if (ModifiedReminder.ShowDialog().Value)
                //{

                //}
            }
        }