Esempio n. 1
0
        public void delete(HoaDonBan hoaDonBan)
        {
            string        sql = "delete from HOADON_BAN where id=" + hoaDonBan.id;
            SqlConnection cnn = Database.getConnection();

            cnn.Open();
            using (SqlCommand cmd = new SqlCommand(sql, cnn))
            {
                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            HoaDonBan hoaDonBan = new HoaDonBan();

            hoaDonBan.id = long.Parse(id);
            hoaDonBanDB.delete(hoaDonBan);
            txtNguoiMua.Text = "";
            txtTenThuoc.Text = "";
            txtMaThuoc.Text  = "";
            txtSoLuong.Text  = "";
            txtDonGia.Text   = "";
            loadDB();
        }
Esempio n. 3
0
        public void update(HoaDonBan hoaDonBan)
        {
            string sql = "update HOADON_BAN set ";

            sql += "NguoiMua =N'" + hoaDonBan.nguoiMua + "',";
            sql += "TenThuoc=N'" + hoaDonBan.tenThuoc + "',";
            sql += "MaThuoc='" + hoaDonBan.maThuoc + "',";
            sql += "SoLuong=" + hoaDonBan.soLuong + ",";
            sql += "DonGia=" + hoaDonBan.donGia + ", ";
            sql += "NgayBan='" + hoaDonBan.ngayBan + "' ";
            sql += "where id=" + hoaDonBan.id;
            SqlConnection cnn = Database.getConnection();

            cnn.Open();
            using (SqlCommand cmd = new SqlCommand(sql, cnn))
            {
                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 4
0
        public void insert(HoaDonBan hoaDonBan)
        {
            string sql = "insert into HOADON_BAN ([NguoiMua], [TenThuoc], [MaThuoc], [SoLuong], [DonGia], [NgayBan]) ";

            sql += "values(@NguoiMua, @TenThuoc, @MaThuoc, @SoLuong, @DonGia, @NgayBan)";
            SqlConnection cnn = Database.getConnection();

            cnn.Open();
            using (SqlCommand cmd = new SqlCommand(sql, cnn))
            {
                cmd.Parameters.AddWithValue("@NguoiMua", hoaDonBan.nguoiMua);
                cmd.Parameters.AddWithValue("@TenThuoc", hoaDonBan.tenThuoc);
                cmd.Parameters.AddWithValue("@MaThuoc", hoaDonBan.maThuoc);
                cmd.Parameters.AddWithValue("@SoLuong", hoaDonBan.soLuong);
                cmd.Parameters.AddWithValue("@DonGia", hoaDonBan.donGia);
                cmd.Parameters.AddWithValue("@NgayBan", hoaDonBan.ngayBan);
                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 5
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtNguoiMua.Text == "" ||
                txtTenThuoc.Text == "" ||
                txtMaThuoc.Text == "" ||
                txtSoLuong.Text == "" ||
                txtDonGia.Text == "")
            {
                MessageBox.Show("Hãy nhập đầy đủ thông tin");
                return;
            }

            HoaDonBan hoaDonBan = new HoaDonBan();

            hoaDonBan.nguoiMua = txtNguoiMua.Text;
            hoaDonBan.tenThuoc = txtTenThuoc.Text;
            hoaDonBan.maThuoc  = txtMaThuoc.Text;
            hoaDonBan.soLuong  = Int32.Parse(txtSoLuong.Text);
            hoaDonBan.donGia   = Int32.Parse(txtDonGia.Text);
            hoaDonBan.ngayBan  = txtNgayBan.Text;
            hoaDonBanDB.insert(hoaDonBan);
            loadDB();
        }