예제 #1
0
        private void MenuItem_ClickDelete(object sender, RoutedEventArgs e)
        {
            //dList.RemoveAt(hclist.SelectedIndex);
            DataRowView myh  = (DataRowView)hclist.SelectedItem;
            dbms        mydb = new dbms("HCdb.sqlite");

            mydb.connect(@"HCdb.sqlite");
            mydb.deleteDt(myh[0].ToString());
            mydb.close();

            try
            {
                string sql = "select * from hourlycheck;";
                mydb.connect("HCdb.sqlite");
                ds = new DataSet();
                var da = new SQLiteDataAdapter(sql, mydb.dbConnection);
                da.Fill(ds);
                hclist.ItemsSource = ds.Tables[0].DefaultView;
                mydb.close();
            }
            catch (Exception mye)
            {
                MessageBox.Show(mye.Message);
            }
        }
예제 #2
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            dbms mydb = new dbms("HCdb.sqlite");

            try
            {
                string sql = "select * from hourlycheck;";
                mydb.connect("HCdb.sqlite");

                var da = new SQLiteDataAdapter(sql, mydb.dbConnection);
                da.Fill(ds);
                hclist.ItemsSource = ds.Tables[0].DefaultView;
                mydb.close();
            }
            catch (Exception mye)
            {
                MessageBox.Show(mye.Message);
            }
        }
예제 #3
0
        private void savebtn_Click(object sender, RoutedEventArgs e)
        {
            if (dt.SelectedDate == null)
            {
                MessageBox.Show("Enter the date");
            }
            else
            {
                if (string.IsNullOrEmpty(initialTb.Text))
                {
                    MessageBox.Show("Enter your initials");
                }
                else
                {
                    Hc ne = n;
                    ne.Dt       = (DateTime)dt.SelectedDate;
                    ne.Initials = initialTb.Text;
                    ne.Id       = no;

                    try
                    {
                        dbms d = new dbms(@"HCdb.sqlite");
                        d.connect(@"HCdb.sqlite");
                        d.insertDt(ne.Dt.ToShortDateString(), ne.H1, ne.H2, ne.H3, ne.H4, ne.H5, ne.H6, ne.H7, ne.H8, ne.H9, ne.H10, ne.H11, ne.H12, ne.H13, ne.H14, ne.H15, ne.H16, ne.H17, ne.H18, ne.H19, ne.H20, ne.H21, ne.H22, ne.H23, ne.H24, ne.Initials, ne.Tc);
                        try
                        {
                            string sql = "select * from hourlycheck;";
                            ds = new DataSet();
                            var da = new SQLiteDataAdapter(sql, d.dbConnection);
                            da.Fill(ds);
                            hclist.ItemsSource = ds.Tables[0].DefaultView;
                            d.close();
                        }
                        catch (Exception mye)
                        {
                            MessageBox.Show(mye.Message);
                        }
                        dt.Text        = null;
                        h1.IsChecked   = false;
                        h2.IsChecked   = false;
                        h3.IsChecked   = false;
                        h4.IsChecked   = false;
                        h5.IsChecked   = false;
                        h6.IsChecked   = false;
                        h7.IsChecked   = false;
                        h8.IsChecked   = false;
                        h9.IsChecked   = false;
                        h10.IsChecked  = false;
                        h11.IsChecked  = false;
                        h12.IsChecked  = false;
                        h13.IsChecked  = false;
                        h14.IsChecked  = false;
                        h15.IsChecked  = false;
                        h16.IsChecked  = false;
                        h17.IsChecked  = false;
                        h18.IsChecked  = false;
                        h19.IsChecked  = false;
                        h20.IsChecked  = false;
                        h21.IsChecked  = false;
                        h22.IsChecked  = false;
                        h23.IsChecked  = false;
                        h24.IsChecked  = false;
                        initialTb.Text = "";
                        n = new Hc();
                        tbshow.IsSelected = true;
                        no++;
                    }
                    catch (Exception myE)
                    {
                        MessageBoxResult d = MessageBox.Show("Record already exist, do you want to update?", "Are you sure", MessageBoxButton.YesNo);
                        if (d == MessageBoxResult.Yes)
                        {
                            dbms dd = new dbms(@"HCdb.sqlite");
                            dd.connect(@"HCdb.sqlite");
                            dd.updateDt(ne.H1, ne.H2, ne.H3, ne.H4, ne.H5, ne.H6, ne.H7, ne.H8, ne.H9, ne.H10, ne.H11, ne.H12, ne.H13, ne.H14, ne.H15, ne.H16, ne.H17, ne.H18, ne.H19, ne.H20, ne.H21, ne.H22, ne.H23, ne.H24, initialTb.Text, ne.Tc, dt.Text);
                            string sql = "select * from hourlycheck;";
                            ds = new DataSet();
                            var da = new SQLiteDataAdapter(sql, dd.dbConnection);
                            da.Fill(ds);
                            hclist.ItemsSource = ds.Tables[0].DefaultView;
                            dd.close();

                            dt.Text        = null;
                            h1.IsChecked   = false;
                            h2.IsChecked   = false;
                            h3.IsChecked   = false;
                            h4.IsChecked   = false;
                            h5.IsChecked   = false;
                            h6.IsChecked   = false;
                            h7.IsChecked   = false;
                            h8.IsChecked   = false;
                            h9.IsChecked   = false;
                            h10.IsChecked  = false;
                            h11.IsChecked  = false;
                            h12.IsChecked  = false;
                            h13.IsChecked  = false;
                            h14.IsChecked  = false;
                            h15.IsChecked  = false;
                            h16.IsChecked  = false;
                            h17.IsChecked  = false;
                            h18.IsChecked  = false;
                            h19.IsChecked  = false;
                            h20.IsChecked  = false;
                            h21.IsChecked  = false;
                            h22.IsChecked  = false;
                            h23.IsChecked  = false;
                            h24.IsChecked  = false;
                            initialTb.Text = "";
                            n = new Hc();
                            tbshow.IsSelected = true;
                        }
                        else if (d == MessageBoxResult.No)
                        {
                        }
                    }
                    n = new Hc();
                }
            }
        }