Example #1
0
        private void butDelete_Click(object sender, EventArgs e)
        {
            if (textIDService.Text == "")
            {
                MessageBox.Show("Hay chon id can xoa tu danh sach!", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            DialogResult result = MessageBox.Show("Ban co chac xoa dich vu co ID = " + textIDService.Text + " khong? (tat ca cac du lieu lien quan deu se bi xoa!)", "WARNING", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);

            switch (result)
            {
            case DialogResult.Cancel: return;

            case DialogResult.Yes:
            {
                SERVICE temp = data.SERVICEs.Find(int.Parse(textIDService.Text));
                data.SERVICEs.Remove(temp);
                data.SaveChanges();
                listService.Clear();
                loadData(0, soLuong);
                dem = 0;
                break;
            }

            case DialogResult.No: return;

            default:
                break;
            }
        }
Example #2
0
        private void listService_SelectedIndexChanged(object sender, EventArgs e)
        {
            textIDService.Text = listService.FocusedItem.Text;
            int     a = int.Parse(textIDService.Text);
            SERVICE b = data.SERVICEs.Find(a);

            textServiceName.Text = b.ServiceName;
            textPrice.Text       = b.Price.ToString();
        }
Example #3
0
        public void updateData()
        {
            SERVICE a = data.SERVICEs.Find(int.Parse(textIDService.Text));

            a.ServiceName = textServiceName.Text;
            decimal b = decimal.Parse(textPrice.Text);

            a.Price = b;
            data.SaveChanges();
        }
Example #4
0
        public void saveData()
        {
            decimal a    = decimal.Parse(textPrice.Text);
            SERVICE temp = new SERVICE()
            {
                ServiceName = textServiceName.Text, Price = a
            };

            data.SERVICEs.Add(temp);
            data.SaveChanges();
        }