示例#1
0
 private void buttonUpdate_Click(object sender, EventArgs e)
 {
     if (textBoxCode.Text == null)
     {
         MessageBox.Show("Code is null!!!");
     }
     else
     {
         Smartphone smartPhone = new Smartphone()
         {
             Code  = Convert.ToInt16(textBoxCode.Text),
             Brand = textBoxBrand.Text,
             Name  = textBoxName.Text,
             Color = textBoxColor.Text,
             Price = Convert.ToInt32(textBoxPrice.Text)
         };
         bool rs = new SmartPhoneBUS().updateSmartPhone(smartPhone);
         if (rs)
         {
             MessageBox.Show("Edit Sucess ^.^");
             List <Smartphone> smartphones = new SmartPhoneBUS().getAllList();
             dataGridView1.DataSource = smartphones;
         }
         else
         {
             MessageBox.Show("Something Wrong!!!");
         }
     }
 }
示例#2
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            string keyword = textBoxSearch.Text;

            if (keyword.Length == 0)
            {
                List <Smartphone> smartphones = new SmartPhoneBUS().getAllList();
                dataGridView1.DataSource = smartphones;
            }
            else
            {
                List <Smartphone> smartphones = new SmartPhoneBUS().searchByName(keyword);
                dataGridView1.DataSource = smartphones;
            }
        }
示例#3
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            int          code   = int.Parse(textBoxCode.Text.Trim());
            DialogResult dialog = MessageBox.Show("Are You Sure?", "CONFIRMATION", MessageBoxButtons.YesNo);

            if (dialog == DialogResult.Yes)
            {
                bool result = new SmartPhoneBUS().deleteSmartPhoneByCode(code);
                if (result)
                {
                    List <Smartphone> smartphones = new SmartPhoneBUS().getAllList();
                    dataGridView1.DataSource = smartphones;
                }
                else
                {
                    MessageBox.Show("Something Wrong!!!");
                }
            }
        }
示例#4
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Smartphone smartphone = new Smartphone()
            {
                Brand = textBoxBrand.Text,
                Name  = textBoxName.Text,
                Color = textBoxColor.Text,
                Price = Convert.ToInt32(textBoxPrice.Text)
            };

            bool rs = new SmartPhoneBUS().addSmartPhone(smartphone);

            if (rs)
            {
                List <Smartphone> smartphones = new SmartPhoneBUS().getAllList();
                dataGridView1.DataSource = smartphones;
            }
            else
            {
                MessageBox.Show("Something Wrong!!!");
            }
        }
示例#5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            List <Smartphone> smartphones = new SmartPhoneBUS().getAllList();

            dataGridView1.DataSource = smartphones;
        }