private void dataKinds_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            Kind kind = new Kind();

            kind.kind = this.dataKinds.CurrentRow.Cells[1].Value.ToString();

            if (kind.kind.Length <= 0)
            {
                return;
            }

            try
            {
                getKindLocal.kind = kind.kind;
            }
            catch
            {
                getKindLocal.kind = "";
            }

            //update data user to database
            KindController.updateKind(getKindLocal);

            BindingSource source = new BindingSource();

            source.DataSource         = KindController.getListKind();
            this.dataKinds.DataSource = source;
        }
        public frmSettings()
        {
            InitializeComponent();

            getKindLocal = new Kind();

            //show
            BindingSource source = new BindingSource();

            source.DataSource         = KindController.getListKind();
            this.dataKinds.DataSource = source;
        }
        public frmHome()
        {
            InitializeComponent();
            pdf      = new PdfViewer();
            pdf.Dock = DockStyle.Fill;
            this.panelReadDocument.Controls.Add(pdf);

            //show data from db

            this.listBoxNearOpen.Items.Clear();

            List <Note> listNearOpen = NoteController.getListNote();

            //sort by time
            for (int i = 0; i < listNearOpen.Count; i++)
            {
                for (int j = listNearOpen.Count - 1; j > i; j--)
                {
                    if (DateTime.Compare(listNearOpen[j].publishAt.Value, listNearOpen[j - 1].publishAt.Value) < 0)
                    {
                        Note noteTemp = listNearOpen[j];
                        listNearOpen[j]     = listNearOpen[j - 1];
                        listNearOpen[j - 1] = noteTemp;
                    }
                }
            }

            for (int i = listNearOpen.Count - 1; i >= 0; i--)
            {
                listBoxNearOpen.Items.Add(listNearOpen[i].filePath.ToString());
            }

            this.listBoxKind.Items.Clear();
            listBoxKind.Items.Add("None");

            List <Kind> listKinds = KindController.getListKind();

            for (int i = 0; i < listKinds.Count; i++)
            {
                listBoxKind.Items.Add(listKinds[i].kind);
            }

            //add data to comboBox

            List <Kind> kinds = KindController.getListKind();

            for (int i = 0; i < kinds.Count; i++)
            {
                lbKind.Items.Add(kinds[i].kind);
            }

            listKind = new List <string>();
        }
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (getKindLocal != null)
            {
                List <Link> listLink = LinkController.getListLink(kindText);
                for (int i = 0; i < listLink.Count; i++)
                {
                    LinkController.deleteLink(listLink[i]);
                }
                KindController.deleteKind(getKindLocal);
            }

            //show
            BindingSource source = new BindingSource();

            source.DataSource         = KindController.getListKind();
            this.dataKinds.DataSource = source;
        }
        private void btnCreate_Click(object sender, EventArgs e)
        {
            Kind kind = new Kind();

            kind.kind = txtKind.Text;

            Kind kindCheck = KindController.getKind(txtKind.Text);

            if (kindCheck == null)
            {
                if (KindController.addKind(kind) == false)
                {
                    MessageBox.Show("Error add kind");
                }
                txtKind.Text = "";
            }

            //show
            BindingSource source = new BindingSource();

            source.DataSource         = KindController.getListKind();
            this.dataKinds.DataSource = source;
        }