예제 #1
0
파일: windows1.cs 프로젝트: llwwlql/windows
        private void button1_Click(object sender, EventArgs e)
        {//添加到单词本
            Form1   form1   = (Form1)this.Parent.Parent;
            DbClass dbClass = new DbClass();
            string  english = this.label1.Text;
            string  chinese = this.label2.Text;
            bool    judge   = dbClass.getInsert(english, chinese, form1.UserId);

            if (judge)
            {
                NotePad note = new NotePad(english, chinese, form1.UserId);
                form1.w2.addNote(note);
                MessageBox.Show("单词保存成功!");
            }
            else
            {
                MessageBox.Show("单词本中已存在!");
            }
        }
예제 #2
0
파일: windows2.cs 프로젝트: llwwlql/windows
        public void addNote(NotePad notePad)
        {
            Panel panel = new Panel();

            panel.Width     = 471;
            panel.Height    = 119;
            panel.Margin    = new Padding(3, 0, 0, 10);
            panel.BackColor = Color.FromArgb(255, 228, 228, 228);

            //英文的label
            Label english = new Label();

            english.Text     = notePad.English;
            english.Font     = new System.Drawing.Font("宋体", 26);
            english.Height   = 35;
            english.Width    = 300;
            english.Location = new Point(38, 21);
            panel.Controls.Add(english);

            //中文翻译的label
            Label chinese = new Label();

            chinese.Text     = notePad.Chinese;
            chinese.Font     = new System.Drawing.Font("宋体", 15);
            chinese.Location = new Point(40, 70);
            chinese.Height   = 21;
            chinese.Width    = 137;
            panel.Controls.Add(chinese);

            //添加删除按钮
            Button button = new Button();

            button.Text     = "";
            button.Location = new Point(405, 35);
            button.Height   = 21;
            button.Width    = 24;
            button.Image    = Properties.Resources.del;
            button.Click   += new EventHandler(but_Click);
            panel.Controls.Add(button);
            flowLayoutPanel1.Controls.Add(panel);
        }
예제 #3
0
파일: DbClass.cs 프로젝트: llwwlql/windows
        public List <NotePad> getNotePad(int userId)
        {
            mycon.Open();
            List <NotePad>  notePads = new List <NotePad>();
            String          sqlStr   = "select * from notepad where uuid = " + userId + " order by english";
            MySqlCommand    mycmd    = new MySqlCommand(sqlStr, mycon);
            MySqlDataReader reader   = mycmd.ExecuteReader();

            while (reader.Read())
            {
                if (reader.HasRows)
                {
                    String  english = reader.GetString(2);
                    String  chinese = reader.GetString(3);
                    NotePad notePad = new NotePad(english, chinese, userId);
                    notePads.Add(notePad);
                }
            }
            mycon.Close();
            return(notePads);
        }