Exemple #1
0
 private void pbDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvClient.Rows.Count > 0)
         {
             this.gbInfor.Text = "Deleting.....";
             // Thực hiện lệnh
             // Lấy thứ tự record hiện hành
             int r = dgvClient.CurrentCell.RowIndex;
             // Lấy MaKH của record hiện hành
             string strCMND = dgvClient.Rows[r].Cells[0].Value.ToString();
             // Viết câu lệnh SQL
             // Hiện thông báo xác nhận việc xóa mẫu tin
             // Khai báo biến traloi
             DialogResult traloi;
             // Hiện hộp thoại hỏi đáp
             traloi = MessageBox.Show("Are you sure?", "Delete row",
                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             // Kiểm tra có nhắp chọn nút Ok không?
             if (traloi == DialogResult.Yes)
             {
                 dbClient.DeleteClient(ref err, strCMND);
                 if (err == "")
                 {
                     // Thông báo
                     MessageBox.Show("Deleted successfully!");
                     // Cập nhật lại DataGridView
                     LoadData();
                 }
                 else
                 {
                     this.gbInfor.Text = "Information";
                     // Thông báo
                     MessageBox.Show("Client is still using room !", "Delete failed!");
                 }
             }
             else
             {
                 this.gbInfor.Text = "Information";
                 // Thông báo
                 MessageBox.Show("Delete failed!");
             }
         }
     }
     catch (SqlException)
     {
         this.gbInfor.Text = "Information";
         MessageBox.Show("Delete failed!");
     }
 }
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     if (dataPartners.Rows.Count != 0)
     {
         int      i          = dataPartners.SelectedCells[0].RowIndex;
         int      selectedId = Convert.ToInt32(dataPartners.Rows[i].Cells[0].Value.ToString());
         BLClient bl         = new BLClient();
         string   message    = bl.DeleteClient(selectedId);
         if (String.IsNullOrWhiteSpace(message))
         {
             dataPartners.Rows.RemoveAt(i);
         }
         else
         {
             MessageBox.Show(message);
         }
     }
     else
     {
         MessageBox.Show("Nu se poate sterge niciun client deoarece nu exista.", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
Exemple #3
0
        //private void BtnModify_Click(object sender, EventArgs e)
        //{
        //    if (dataGridClient.SelectedRows.Count == 0)
        //    {
        //        MessageBox.Show("Trebuie sa selectati un client.");
        //        return;
        //    }

        //    else
        //    {
        //        ClientModule client = (ClientModule)dataGridClient.SelectedRows[0].DataBoundItem;
        //        UpdateClientForm updateClientForm = new UpdateClientForm(client.ClientId);
        //        updateClientForm.Show();
        //        this.Hide();
        //        updateClientForm.FormClosed += UpdateClientForm_FormClosed;

        //    }


        //}

        //private void UpdateClientForm_FormClosed(object sender, FormClosedEventArgs e)
        //{
        //    this.Close();
        //}

        private void BtnDelete_Click(object sender, EventArgs e)
        {
            if (dataGridClient.SelectedRows.Count == 0)
            {
                MessageBox.Show("Trebuie sa selectati un client.");
                return;
            }
            BLClient     bLClient = new BLClient();
            ClientModule client   = (ClientModule)dataGridClient.SelectedRows[0].DataBoundItem;

            //UpdateClientForm updateClientForm = new UpdateClientForm(client.ClientId);
            if (MessageBox.Show("Sunteti sigur ca vreiti sa stergeti clientul " + client.ClientName + " " + client.ClientSurname + "?", "Mesaj de avertizare!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                bLClient.DeleteClient(client.ClientId);
                MessageBox.Show(client.ClientName + " " + client.ClientSurname + " a fost sters cu succes.");
                List <ClientModule> list = bLClient.GetClientList(-1, "", "", "", "", "");
                dataGridClient.DataSource = list;
            }
            else
            {
                return;
            }
        }