Beispiel #1
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            string            keyword     = textBoxSearch.Text;
            List <Smartphone> smartPhones = new SmartPhoneBUS().searchByName(keyword);

            dataGridView1.DataSource = smartPhones;
        }
Beispiel #2
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!!!");
         }
     }
 }
        protected void getAndBindingList()
        {
            List <Smartphone> smartphones = new SmartPhoneBUS().getAllList();

            GridView1.DataSource = smartphones;
            GridView1.DataBind();
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string            keyword     = TextBoxSearch.Text.Trim();
            List <Smartphone> smartphones = new SmartPhoneBUS().searchByName(keyword);

            GridView1.DataSource = smartphones;
            GridView1.DataBind();
        }
Beispiel #5
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!!!");
                }
            }
        }
        protected void btnDeleteConfirm_Click(object sender, EventArgs e)
        {
            int  code = Convert.ToInt32(TextBoxCode.Text);
            bool rs   = new SmartPhoneBUS().deleteSmartPhoneByCode(code);

            if (rs)
            {
                getAndBindingList();
                ClientScript.RegisterStartupScript(this.GetType(), "ToastSucess", "showToastSucess();", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ToastFail", "showToastFail();", true);
            }
            TextBoxBrand.Text = "";
            TextBoxCode.Text  = "";
            TextBoxColor.Text = "";
            TextBoxName.Text  = "";
            TextBoxPrice.Text = "";
        }
Beispiel #7
0
        private void button1_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("Somgthing Wrong!!!");
            }
        }
        protected void btSubmit_Click1(object sender, EventArgs e)
        {
            Smartphone smartphone = new Smartphone()
            {
                Name  = TextBoxName.Text.Trim(),
                Brand = TextBoxBrand.Text.Trim(),
                Color = TextBoxColor.Text.Trim(),
                Price = Convert.ToInt32(TextBoxPrice.Text),
            };

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

            if (rs)
            {
                getAndBindingList();
                ClientScript.RegisterStartupScript(this.GetType(), "ToastSucess", "showToastSucess();", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ToastFail", "showToastFail();", true);
            }
        }
Beispiel #9
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            List <Smartphone> smartPhones = new SmartPhoneBUS().getAllList();

            dataGridView1.DataSource = smartPhones;
        }