Beispiel #1
0
 public void LoadData()
 {
     txt_cityID.ResetText();
     txt_cityName.ResetText();
     workBaseCity                = new WorkBaseCity();
     dataGridView1.DataSource    = workBaseCity.GetCities();
     this.btn_add.Enabled        = true;
     this.btn_del.Enabled        = true;
     this.btn_edit.Enabled       = true;
     this.btn_reload.Enabled     = true;
     this.btn_exit.Enabled       = true;
     this.btn_save.Enabled       = false;
     this.txt_cityID.Enabled     = false;
     this.dataGridView1.ReadOnly = true;
 }
Beispiel #2
0
        private void btn_del_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult;

            dialogResult = MessageBox.Show("Chắc không?", "Trả lời", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (dialogResult == DialogResult.OK)
            {
                workBaseCity = new WorkBaseCity();
                if (workBaseCity.RemoveCity(txt_cityID.Text, ref err))
                {
                    LoadData();
                    MessageBox.Show("Xoa Thanh Cong");
                }
                else
                {
                    MessageBox.Show("Xoa Khong Thanh Cong", "Loi", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Khong thuc hien xoa");
            }
        }
Beispiel #3
0
 private void btn_save_Click(object sender, EventArgs e)
 {
     if (!txt_cityID.Text.Trim().Equals(""))
     {
         // Thêm dữ liệu
         if (Adding)
         {
             workBaseCity = new WorkBaseCity();
             if (workBaseCity.AddCity(txt_cityID.Text, txt_cityName.Text, ref err))
             {
                 LoadData();
                 MessageBox.Show("Them Thanh Cong");
             }
             else
             {
                 MessageBox.Show("Them Khong Thanh Cong", "Loi", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
             }
         }
         else //sua
         {
             workBaseCity = new WorkBaseCity();
             if (workBaseCity.UpdateCity(txt_cityID.Text, txt_cityName.Text, ref err))
             {
                 LoadData();
                 MessageBox.Show("Sua Thanh Cong");
             }
             else
             {
                 MessageBox.Show("Sua Khong Thanh Cong", "Loi", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
             }
         }
     }
     this.Adding = false;
     LoadData();
     this.txt_cityID.Enabled = false;
 }