Ejemplo n.º 1
0
        private void btn_xoa_Click(object sender, EventArgs e)
        {
            // get data user selected;
            var selected_r = dtgv.SelectedRows;

            if (selected_r.Count > 0)
            {
                if (Utils.confirm_delete())
                {
                    bool   check     = true;
                    string err_infor = "";
                    foreach (DataGridViewRow item in selected_r)
                    {
                        var temp = nhaxuatban_ctrl.delete_nhaxuatban(int.Parse(item.Cells[0].Value.ToString()));
                        switch (temp.errcode)
                        {
                        case ErrorCode.NaN:
                            break;

                        case ErrorCode.sucess:
                            Utils.erase_text_box(new List <TextBox> {
                                txt_manhaxuatban, txt_diachi, txt_sdt, txt_tennhaxuatban
                            });
                            Utils.readOnly_text_box(new List <TextBox> {
                                txt_diachi, txt_sdt, txt_tennhaxuatban
                            }, true);
                            option = Option.Nodata;
                            break;

                        case ErrorCode.fail:
                            check     = false;
                            err_infor = temp.errInfor;
                            break;

                        default:
                            break;
                        }
                    }

                    if (check)
                    {
                        MessageBox.Show(Constants.success_delete);
                        load_data();
                    }
                    else
                    {
                        MessageBox.Show(Constants.not_allow_to_delete);
                    }
                }
            }
        }