Beispiel #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Napominanie);
            // Create your application here

            mToolbar      = FindViewById <SupportToolbar>(Resource.Id.toolBar1);
            mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.Drawer_layout1);
            mLeftDrawer   = FindViewById <ListView>(Resource.Id.left_drawer1);
            listView      = FindViewById <ListView>(Resource.Id.listView1);
            SetSupportActionBar(mToolbar);

            mLeftDataSet = new List <string>();
            mLeftDataSet.Add("Расписание");
            // mLeftDataSet.Add("Преподаватели");
            mLeftDataSet.Add("Напоминание");
            //mLeftDataSet.Add("Местоположение");
            mLeftDataSet.Add("Выход");
            mLeftAdapter        = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
            mLeftDrawer.Adapter = mLeftAdapter;
            mDrawerToggle       = new MyActionBarDrawerToggle(
                this,                        //host activity
                mDrawerLayout,               //DrawerLayout
                Resource.String.naponinanie, //открыто сообщение
                Resource.String.naponinanie  //зактрыто сообщение
                );
            mLeftDrawer.ItemClick += mLeftDrawer_ItemClick;

            Create_Database dbr = new Create_Database();
            var             res = dbr.GetAllRecords();

            if (res != "")
            {
                string[] str = res.Split('\n');
                for (int i = 0; i < str.Length - 1; i++)
                {
                    string   str2 = "";
                    string[] str1 = str[i].Split(' ');
                    for (int j = 3; j < str1.Length; j++)
                    {
                        str2 += str1[j] + " ";
                    }
                    tableItems.Add(new TableItem()
                    {
                        Heading = str1[1] + " " + str1[2], SubHeading = str2
                    });
                }
                listView.Adapter = new HomeScreenAdapter(this, tableItems);
            }

            listView.ItemClick     += listView_ItemClick;
            listView.ItemLongClick += listView_ItemLongClick;


            mDrawerLayout.SetDrawerListener(mDrawerToggle);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(true);
            mDrawerToggle.SyncState();
        }
Beispiel #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetContentView(Resource.Layout.Add_Napominanie);

            Time        = FindViewById <Button>(Resource.Id.button2);
            Data        = FindViewById <Button>(Resource.Id.button1);
            Save        = FindViewById <Button>(Resource.Id.Save);
            Cancel      = FindViewById <Button>(Resource.Id.Cancel);
            mToolbar    = FindViewById <SupportToolbar>(Resource.Id.toolBarr);
            Napominalka = FindViewById <EditText>(Resource.Id.Napominanie);
            SetSupportActionBar(mToolbar);


            Time.Click  += (object sender, EventArgs e) => ShowDialog(Chas);
            Data.Click  += (object sender, EventArgs e) => ShowDialog(Den);
            nomer_striki = Intent.GetIntExtra("id", 0);
            hour         = DateTime.Now.Hour;
            minute       = DateTime.Now.Minute;
            data         = DateTime.Today;
            if (nomer_striki < 0)
            {
                UpdateTextVremia();
                UpdateTextData();
            }
            else
            {
                Create_Database dbr = new Create_Database();
                var             res = dbr.GetAllRecords();
                if (res != "")
                {
                    string[] str  = res.Split('\n');
                    string   str2 = "";
                    string[] str1 = str[nomer_striki].Split(' ');
                    id        = Convert.ToInt32(str1[0]);
                    Data.Text = str1[1];
                    Time.Text = str1[2];
                    for (int j = 3; j < str1.Length; j++)
                    {
                        str2 += str1[j] + " ";
                    }
                    Napominalka.Text = str2;
                }
            }


            Save.Click   += Save_Click;
            Cancel.Click += Cancel_Click;
        }
Beispiel #3
0
        void listView_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);
            //alert.SetTitle("Confirm delete");
            alert.SetMessage("Удалить напоминание?");
            alert.SetPositiveButton("Удалить", (senderAlert, args) =>
            {
                int id = 0;
                Create_Database dbr = new Create_Database();
                var res             = dbr.GetAllRecords();
                if (res != "")
                {
                    string[] str  = res.Split('\n');
                    string[] str1 = str[e.Position].Split(' ');
                    id            = Convert.ToInt32(str1[0]);
                }
                var res1 = dbr.RemoveTask(id);
                Toast.MakeText(this, res1, ToastLength.Short).Show();
                var res2 = dbr.GetAllRecords();
                tableItems.Clear();
                if (res2 != "")
                {
                    string[] str = res2.Split('\n');
                    for (int i = 0; i < str.Length - 1; i++)
                    {
                        string str2   = "";
                        string[] str1 = str[i].Split(' ');
                        for (int j = 3; j < str1.Length; j++)
                        {
                            str2 += str1[j] + " ";
                        }
                        tableItems.Add(new TableItem()
                        {
                            Heading = str1[1] + " " + str1[2], SubHeading = str2
                        });
                    }
                }
                listView.Adapter = new HomeScreenAdapter(this, tableItems);
            });

            alert.SetNegativeButton("Отмена", (senderAlert, args) => { });

            Dialog dialog = alert.Create();

            dialog.Show();
        }
Beispiel #4
0
        void Save_Click(object sender, EventArgs e)
        {
            string          data  = Data.Text + " " + Time.Text;
            string          napom = Napominalka.Text;
            string          res   = "";
            Create_Database dbr   = new Create_Database();

            if (nomer_striki < 0)
            {
                res = dbr.Insertrecord(napom, data);
            }
            else
            {
                res = dbr.UpdateRecord(id, data, napom);
            };
            var intent = new Intent(this, typeof(Napominanie));

            this.StartActivity(intent);
            Toast.MakeText(this, res, ToastLength.Short).Show();
        }
Beispiel #5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            EnterButton  = FindViewById <Button>(Resource.Id.button1);
            mProgressbar = FindViewById <ProgressBar>(Resource.Id.progressBar1);
            mCheckBox    = FindViewById <CheckBox>(Resource.Id.checkBox1);
            mUserName    = FindViewById <EditText>(Resource.Id.Namber);
            mPassword    = FindViewById <EditText>(Resource.Id.Password);
            mToolbar     = FindViewById <SupportToolbar>(Resource.Id.toolStart);
            SetSupportActionBar(mToolbar);
            // создание БД
            Create_Database bdr    = new Create_Database();
            var             result = bdr.CeateDB();

            bdr.CreateTable();

            EnterButton.Click += (object sender, EventArgs e) =>
            {
                if (IsOnline()) //проверка соединения с интернетом
                {
                    FragmentTransaction transaction = FragmentManager.BeginTransaction();
                    Enter_Dialog        enter       = new Enter_Dialog();
                    enter.Show(transaction, "dialog fragment");
                    enter.mEnterButtonArg += enter_mEnterButtonArg;
                }
                else
                {
                    Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);
                    alert.SetMessage("Нет соединения с интеренетом!");
                    alert.SetPositiveButton("Ок", (senderAlert, args) => { });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                }
            };
        }