Esempio n. 1
0
        private void bt_CNDL_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tb_TenDauSach.Text))
            {
                MessageBox.Show("Không được để trống tên đầu sách.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_TenDauSach.Focus();
            }
            else if (string.IsNullOrEmpty(cbb_TheLoaiSach.Text))
            {
                MessageBox.Show("Không được để trống thể loại sách.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbb_TheLoaiSach.Focus();
            }
            else if (string.IsNullOrEmpty(tb_TenTacGia.Text))
            {
                MessageBox.Show("Không được để trống tên tác giả.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_TenTacGia.Focus();
            }
            else if (string.IsNullOrEmpty(tb_NhaXuatBan.Text))
            {
                MessageBox.Show("Không được để trống nhà xuất bản.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_NhaXuatBan.Focus();
            }
            else if (string.IsNullOrEmpty(tb_NamXuatBan.Text))
            {
                MessageBox.Show("Không được để trống năm xuất bản.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_NamXuatBan.Focus();
            }
            else if (string.IsNullOrEmpty(tb_GiaTien.Text))
            {
                MessageBox.Show("Không được để trống giá tiền", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_GiaTien.Focus();
            }
            else if (string.IsNullOrEmpty(tb_SoLuong.Text))
            {
                MessageBox.Show("Không được để trống số lượng.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_SoLuong.Focus();
            }
            else if (string.IsNullOrEmpty(tb_DonGia.Text))
            {
                MessageBox.Show("Không được để trống đơn giá.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_DonGia.Focus();
            }
            else
            {
                try
                {
                    SachService sv = new SachService();
                    SachDTO     s  = new SachDTO();

                    TenDauSach    = tb_TenDauSach.Text;
                    TenLoaiSach   = cbb_TheLoaiSach.Text;
                    TenTG         = tb_TenTacGia.Text;
                    NhaXB         = tb_NhaXuatBan.Text;
                    NamXB         = Int32.Parse(tb_NamXuatBan.Text);
                    GiaTien       = HelperGUI.Instance.checkMoney(GiaTien, tb_GiaTien);
                    SoLuong       = Int32.Parse(tb_SoLuong.Text);
                    DonGia        = HelperGUI.Instance.checkMoney(DonGia, tb_DonGia);
                    NgayNhap      = dt_NgayNhap.Value;
                    s.IDTacGia    = IDTacGia;
                    s.IDSach      = IDSach;
                    s.TenTG       = TenTG;
                    s.IDDauSach   = IDDauSach;
                    s.NamXB       = NamXB;
                    s.NhaXB       = NhaXB;
                    s.GiaTien     = GiaTien;
                    s.DonGia      = DonGia;
                    s.SoLuong     = SoLuong;
                    s.TenDauSach  = TenDauSach;
                    s.TenLoaiSach = TenLoaiSach;
                    s.NgayNhap    = NgayNhap;
                    sv.ADDFormSach(s);
                    MessageBox.Show("Thêm thành công!");
                    fillTheLoaiSachDataFromTableSach();
                    HelperGUI.ResetAllControls(groupControl_TTS);
                }
                catch
                {
                }
            }
        }