Beispiel #1
0
        private void btnThem_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 (Exception ex)
            {
                MessageBox.Show("Kiểu dữ liệu bạn nhập bị sai.Vui lòng nhập lại");
                return;
            }

            if (bus_sach.themSach(et_Sach))
            {
                MessageBox.Show("Bạn Đã thêm thành công.");
                dgvSach.DataSource = bus_sach.getSach();
            }
            else
            {
                MessageBox.Show("Bạn thêm không thành công.");
            }
        }
Beispiel #2
0
        public void addParameter(SqlCommand cmd, ET_Sach sach, String[] strNameParametor)
        {
            //string maSach, string maGH, string tenSach, string theloai, string tenNCC, string tacgia, string maNV, float giaban, DateTime nxb, DateTime ngaynhap, int soluong, int giamgia

            ArrayList list = sach.getAllProperties();

            foreach (string item in strNameParametor)
            {
                SqlParameter pt = new SqlParameter(item, list[Array.IndexOf(strNameParametor, item)]);
                cmd.Parameters.Add(pt);
            }
        }
Beispiel #3
0
 public bool suaSach(ET_Sach sach)
 {
     try
     {
         SqlCommand cmd = HandleCMD.proc("sp_SuaSach", _con);
         addParameter(cmd, sach, strNameParameter);
         if (cmdExecuted(cmd))
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(false);
 }
Beispiel #4
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.");
            }
        }
Beispiel #5
0
 public bool themSach(ET_Sach sach)
 {
     try
     {
         this.openDB();
         SqlCommand cmd = HandleCMD.proc("sp_ThemSach", _con);
         addParameter(cmd, sach, strNameParameter);
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     finally
     {
         this.closeDB();
     }
     return(false);
 }
Beispiel #6
0
 public bool suaSach(ET_Sach et_Sach)
 {
     return(dal_Sach.suaSach(et_Sach));
 }
Beispiel #7
0
 public bool themSach(ET_Sach et_Sach)
 {
     return(dal_Sach.themSach(et_Sach));
 }