Пример #1
0
        public void them()
        {
            Sach_DTO ds = new Sach_DTO();

            ds.MaTheLoai = int.Parse(cmbTheLoai.SelectedValue.ToString());
            try
            {
                ds.TenSach = txtTenSach.Text;
            }
            catch
            {
                MessageBox.Show("Tên sách không được rỗng!");
                return;
            }
            try
            {
                ds.TacGia = txtTacGia.Text;
            }
            catch
            {
                MessageBox.Show("Tên tác giả không được rỗng!");
                return;
            }
            ds.SoLuongTon = 0;
            if (txtDonBanSach.Text != "")
            {
                try
                {
                    ds.DonGiaBan = UInt64.Parse(txtDonBanSach.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Đơn giá bán phải là số");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Đơn giá bán không được bỏ trống");
                return;
            }

            string ketQua = Sach_BUS.ThemSach(ds);

            if (ketQua != "Success")
            {
                MessageBox.Show(ketQua);
                return;
            }
            MessageBox.Show("Thêm đầu sách thành công");
            HienThiDanhSachSach();
        }