Beispiel #1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            ET_Sach et_Sach = null;

            try
            {
                et_Sach = new ET_Sach(txtMaSach.Text
                                      , cboGH.SelectedValue.ToString()
                                      , txtTenSach.Text
                                      , txtTheLoai.Text
                                      , txtTenNXB.Text
                                      , txtTacGia.Text
                                      , txtMaNV.Text
                                      , float.Parse(txtGiaBan.Text)
                                      , dtpNXB.Value
                                      , dtpNgayNhap.Value
                                      , Int32.Parse(txtSoLuong.Text)
                                      , Int32.Parse(txtGiamGia.Text));
            }
            catch (InvalidCastException ex)
            {
                MessageBox.Show("Kiểu dữ liệu bạn nhập bị sai.Vui lòng nhập lại");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Dữ liệu bạn hiện đang trống");
                return;
            }

            DialogResult r = MessageBox.Show("Bạn có muốn sữa dữ liệu này không", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (r == DialogResult.No)
            {
                MessageBox.Show("Bạn đã hủy sữa");
                return;
            }

            if (bus_sach.suaSach(et_Sach))
            {
                MessageBox.Show("Bạn Đã sữa thành công.");
            }
            else
            {
                MessageBox.Show("Bạn sữa không thành công.");
            }
        }