CapDemo.GUI.CreateCatalogueNew.txt_NameCatalogue_KeyDown C# (CSharp) Метод

txt_NameCatalogue_KeyDown() приватный Метод

private txt_NameCatalogue_KeyDown ( object sender, KeyEventArgs e ) : void
sender object
e System.Windows.Forms.KeyEventArgs
Результат void
        private void txt_NameCatalogue_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (txt_NameCatalogue.Text.Trim() == "")
                {
                    MessageBox.Show("Vui lòng nhập tên chủ đề!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    CatalogueBL CatBL = new CatalogueBL();
                    Catalogue Cat = new Catalogue();
                    Cat.NameCatalogue = txt_NameCatalogue.Text.Trim();
                    if (CatBL.AddCatalogue(Cat) == true)
                    {
                        //notifyIcon1.Icon = SystemIcons.Information;
                        //notifyIcon1.BalloonTipText = "Thêm chủ đề \"" + txt_NameCatalogue.Text.Trim() + "\" thành công";
                        //notifyIcon1.ShowBalloonTip(5000);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Chủ đề này đã tồn tại trong hệ thống!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                }
            }
        }