예제 #1
0
        private void dataGridView_DoubleClick(object sender, EventArgs e)
        {
            string mahangxoa, sql;
            Double thanhtienxoa, soluongxoa, sl, slcon, tong, tongmoi;

            if (dataGridView.Rows.Count == 0)
            {
                MessageBox.Show("Không có dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if ((MessageBox.Show("Bạn có chắc chắn muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
            {
                //Xóa hàng và cập nhật lại số lượng hàng
                mahangxoa    = dataGridView.CurrentRow.Cells["Mahang"].Value.ToString();
                soluongxoa   = Convert.ToDouble(dataGridView.CurrentRow.Cells["Soluong"].Value.ToString());
                thanhtienxoa = Convert.ToDouble(dataGridView.CurrentRow.Cells["Thanhtien"].Value.ToString());
                sql          = "DELETE tblChitietHDN WHERE MaHDN=N'" + txtMahoadon.Text + "' AND Mahang = N'" + mahangxoa + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                // Cập nhật lại số lượng cho các mặt hàng
                sl    = Convert.ToDouble(ThucthiSQL.DocBang("SELECT Soluongtonkho FROM tblHang WHERE Mahang = N'" + mahangxoa + "'").Rows[0][0].ToString());
                slcon = sl - soluongxoa;
                sql   = "UPDATE tblHang SET Soluongtonkho =" + slcon + " WHERE Mahang= N'" + mahangxoa + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                // Cập nhật lại tổng tiền cho hóa đơn bán
                tong    = Convert.ToDouble(ThucthiSQL.DocBang("SELECT Tongtien FROM tblHoadonnhap WHERE MaHDN = N'" + txtMahoadon.Text + "'").Rows[0][0].ToString());
                tongmoi = tong - thanhtienxoa;
                sql     = "UPDATE tblHoadonnhap SET Tongtien =" + tongmoi + " WHERE MaHDN = N'" + txtMahoadon.Text + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                txtTongtien.Text = tongmoi.ToString();
                lblBangchu.Text  = "Bằng chữ: " + ThucthiSQL.ChuyenSoSangChu(tongmoi.ToString());
                Hienthi_Luoi();
            }
        }
예제 #2
0
        private void btnBaoCao_Click(object sender, EventArgs e)
        {
            if ((txtNam.Text == ""))
            {
                MessageBox.Show("Hãy nhập đầy đủ năm!!!", "Yeu cau ...",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            int nam        = Convert.ToInt32(txtNam.Text);
            int namhientai = DateTime.Now.Year;

            if (nam < 2000 || nam > namhientai)
            {
                MessageBox.Show("Năm bạn nhập không hợp lệ!!! (Năm nhập từ 2000 đến " + DateTime.Now.Year + ")", "Yêu cầu nhập lại",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string sql;

            sql = "select top 5 tblNhan_vien.MaNV,TenNV,sum(tblHDB.Tong_tien) as tongsotien FROM tblNhan_vien join tblHDB on tblNhan_vien.MaNV=tblHDB.MaNV WHERE (YEAR(tblHDB.NgayBan)=" + txtNam.Text + ") GROUP BY tblNhan_vien.MaNV,TenNV Order by tongsotien desc";
            DataTable tblQuy;

            tblQuy = ThucthiSQL.DocBang(sql);
            if (tblQuy.Rows.Count == 0)
            {
                MessageBox.Show("Không có bản ghi thỏa mãn điều kiện!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("Có " + tblQuy.Rows.Count + " bản ghi thỏa mãn điều kiện!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            dataGridView1.DataSource = tblQuy;
            HienthiLuoi();
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            btnXoa.Enabled = true;
            if (txtMaMT.Text == "")
            {
                MessageBox.Show("Bạn phải nhập mã máy tính", "Thông báo");
                txtMaMT.Focus();
                return;
            }

            String sql;

            sql = " SELECT Ma_mayVT FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" + txtMaMT.Text + "'";
            DataTable dt = ThucthiSQL.DocBang(sql);

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Mã này đã có, bạn phải nhập mã khác", "Thông báo");
                txtMaMT.Focus();
                txtMaMT.Text = "";
            }
            sql = "INSERT INTO dboMay_vi_tinh(Ma_mayVT,Ten_mayVT,Ma_hang_SX,Ma_loai_may,Ma_RAM,Ma_chip,Ma_MH,Ma_co_MH,Ma_o_cung,Ma_dungluong,Ma_chuot,Ma_ban_phim,Thoi_han_BH,So_luong,Gia_nhap,Gia_ban) VALUES (N'" +
                  txtMaMT.Text + "',N'" + txtTenmaytinh.Text + "',N'" + txtNSX.Text + "',N'" + cboLoaimay.Text + "',N'" + cboRAM.Text + "',N'" + txtChip.Text + "',N'" + cboManhinh.Text + "',N'" + cboKichthuoc.Text + "',N'" + cboLoaiocung.Text + "',N'" + cboOcung.Text + "',N'" + txtChuot.Text + "',N'" + txtBanphim.Text + "'," + txtBaoHanh.Text + "," + txtSoluong.Text + "," + txtGiaNhap.Text + "," + txtGiaBan.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            Hienthi_Luoi();
        }
예제 #4
0
        private void DelUpdateHang(string mahang, double slxoa, double Giabanxoa)
        {
            double sl = Convert.ToDouble(ThucthiSQL.DocBang("select Soluongtonkho from tblHang where Mahang=N'" +
                                                            mahang + "'").Rows[0][0].ToString());
            double slmoi = sl + slxoa;
            string sql   = "update tblHang set Soluongtonkho=" + slmoi + "where Mahang=N'" + mahang + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
        }
예제 #5
0
        private void btnHuy_Click(object sender, EventArgs e)
        {
            string    sql = "SELECT Ma_mayVT,So_luong,Don_gia FROM tblChitietHDN WHERE Ma_mayVT = N'" + txtMahoadon.Text + "'";
            DataTable tbl = ThucthiSQL.DocBang(sql);

            sql = "DELETE tblHDN WHERE Ma_HDN= N'" + txtMahoadon.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            ResetValues();
            Hienthi_Luoi();
        }
예제 #6
0
        private void DelUpdateTongtien(string madonxoa, double thanhtienxoa)
        {
            double tong    = Convert.ToDouble(ThucthiSQL.DocBang("Select Tongtien from tblHoadonnhap where MaHDN=N'" + madonxoa + "'").Rows[0][0].ToString());
            double tongmoi = tong - thanhtienxoa;
            string sql     = "update tblHoadonnhap SET Tongtien=" + tongmoi + "where MaHDN=N'" + madonxoa + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
            txtTongtien.Text = tongmoi.ToString();
            lblBangchu.Text  = "Bằng chữ: " + ThucthiSQL.ChuyenSoSangChu(tongmoi.ToString());
        }
예제 #7
0
        private void DelUpdateSo_luongMVT(string ma_mayVTxoa, double slxoa, double giabanxoa)
        {
            //Cập nhập số lượng máy tính vào bảng máy vi tính  theo công thức
            //Slmoi= slg trong bảng máy vi tính - slg đã bị xóa
            double sl    = Convert.ToDouble(ThucthiSQL.DocBang("SELECT So_luong FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" + ma_mayVTxoa + "'").Rows[0][0].ToString());
            double slmoi = sl - slxoa;
            string sql   = "UPDATE dboMay_vi_tinh SET So_luong=" + slmoi + "WHERE Ma_mayVT=N'" + ma_mayVTxoa + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
        }
예제 #8
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (cboMamayvitinh.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã máy vi tính", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboMamayvitinh.Focus();
                return;
            }
            if ((txtSo_luong.Text.Trim().Length == 0) || (txtSo_luong.Text == "0"))
            {
                MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSo_luong.Text = "";
                txtSo_luong.Focus();
                return;
            }
            if (txtDon_gia.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập đơn giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDon_gia.Text = "";
                txtDon_gia.Focus();
                return;
            }
            string sql = "SELECT Ma_mayVT FROM tblChitietHDN WHERE Ma_mayVT=N'" + cboMamayvitinh.Text +
                         "' AND Ma_HDN = N'" + txtMahoadon.Text.Trim() + "'";

            if (ThucthiSQL.DocBang(sql).Rows.Count > 0)
            {
                MessageBox.Show("Mã hàng này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ResetValuesMaytinh();
                cboMamayvitinh.Focus();
                return;
            }

            sql = "INSERT INTO tblChitietHDN(Ma_HDN,Ma_mayVT,So_luong,Don_gia,Thanh_tien) VALUES(N'" +
                  txtMahoadon.Text.Trim() + "','" + cboMamayvitinh.Text.ToString() + "'," + txtSo_luong.Text +
                  "," + txtDon_gia.Text + "," + txtThanh_tien.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            Hienthi_Luoi();
            //
            double tong = Convert.ToDouble(ThucthiSQL.DocBang("SELECT Thanh_tien FROM tblHDN WHERE Ma_HDN=N'" +
                                                              txtMahoadon.Text + "'").Rows[0][0].ToString());
            double tongmoi = tong + Convert.ToDouble(txtThanh_tien.Text);

            sql = "UPDATE tblHDN SET Thanh_tien =" + tongmoi + "WHERE Ma_HDN=N'" + txtMahoadon.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            //
            double sl = Convert.ToDouble(ThucthiSQL.DocBang("SELECT So_luong FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" +
                                                            cboMamayvitinh.Text + "'").Rows[0][0].ToString());
            double slmoi = sl + Convert.ToDouble(txtSo_luong.Text);

            sql = "UPDATE dboMay_vi_tinh SET So_luong=" + slmoi + "WHERE Ma_mayVT=N'" + cboMamayvitinh.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
        }
예제 #9
0
파일: frmHang.cs 프로젝트: ThanhSarah/TTCN2
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtTenHH.Text == "")
            {
                MessageBox.Show("Bạn phải nhập tên hàng hóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenHH.Focus();
                return;
            }
            if (txtDongianhap.Text == "")
            {
                MessageBox.Show("Bạn phải nhập đơn giá nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDongianhap.Focus();
                return;
            }
            if (txtDongiaban.Text == "")
            {
                MessageBox.Show("Bạn phải nhập đơn giá bán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDongiaban.Focus();
                return;
            }
            if (txtSoluong.Text == "")
            {
                MessageBox.Show("Bạn phải nhập số lượng tồn kho", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSoluong.Focus();
                return;
            }
            sql  = "select * from tblHang where Mahang = N'" + txtMaHH.Text + "'";
            tblH = ThucthiSQL.DocBang(sql);
            if (tblH.Rows.Count == 0)
            {
                sql = "INSERT INTO tblHang(Mahang, Tenhang, Dongiaban, Dongianhap, Soluongtonkho, Xuatxu, Anh, Ghichu) Values (N'" + txtMaHH.Text +
                      "',N'" + txtTenHH.Text + "',N'" + txtDongiaban.Text + "',N'" + txtDongianhap.Text + "',N'" + txtSoluong.Text + "',N'" + txtXuatxu.Text + "',N'" + txtAnh.Text + "',N'" + txtGhichu.Text + "')";
            }
            else
            {
                sql = "UPDATE tblHang SET Tenhang = N'" + txtTenHH.Text + "', Dongiaban = N'" + txtDongiaban.Text + "', Dongianhap = N'" + txtDongianhap.Text + "', Soluongtonkho = N'" + txtSoluong.Text + "', Xuatxu = N'" + txtXuatxu.Text + "', Anh = N'" + txtAnh.Text + "', Ghichu = N'" + txtGhichu.Text + "' where Mahang = N'" + txtMaHH.Text + "'";
            }

            ThucthiSQL.CapNhatDuLieu(sql);
            btnThem.Enabled = true;
            btnLuu.Enabled  = false;
            btnHuy.Enabled  = false;
            btnXoa.Enabled  = false;
            ResetValues();
            grbThongtinhang.Enabled = false;
            sql  = "SELECT * FROM tblHang";
            tblH = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblH;
            Hienthi_Luoi();
        }
예제 #10
0
        private void btnThemhang_Click(object sender, EventArgs e)
        {
            if (cboMahang.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboMahang.Focus();
                return;
            }
            if (txtSoluong.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSoluong.Text = "";
                txtSoluong.Focus();
                return;
            }
            if (txtGiamgia.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập giảm giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtGiamgia.Focus();
                return;
            }
            string sql = "SELECT * FROM tblChitietHDB WHERE Mahang=N'" + cboMahang.Text + "' AND MaHDB=N'" + txtMahoadon.Text + "'";

            if (ThucthiSQL.DocBang(sql).Rows.Count > 0)
            {
                MessageBox.Show("Mã sách này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ResetValuesHang();
                cboMahang.Focus();
                return;
            }
            sql = "INSERT INTO tblChitietHDB(MaHDB, Mahang, Soluong, Giaban, Giamgia, Thanhtien) VALUES(N'" +
                  txtMahoadon.Text + "',N'" + cboMahang.Text + "', " + txtSoluong.Text +
                  "," + txtDongia.Text + "," + txtGiamgia.Text + "," + txtThanhtien.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            Hienthi_Luoi();
            double tong = Convert.ToDouble(ThucthiSQL.DocBang("select Tongtien from tblHoadonban where MaHDB=N'" +
                                                              txtMahoadon.Text + "'").Rows[0][0].ToString());
            double tongmoi = tong + Convert.ToDouble(txtThanhtien.Text);

            sql = "update tblHoadonban set Tongtien=" + tongmoi + "where MaHDB=N'" + txtMahoadon.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            txtTongtien.Text = tongmoi.ToString();
            lblBangchu.Text  = "Bằng chữ:" + ThucthiSQL.ChuyenSoSangChu(tongmoi.ToString());
            double sl    = Convert.ToDouble(ThucthiSQL.DocBang("select Soluongtonkho from tblHang where Mahang=N'" + cboMahang.Text + "'").Rows[0][0].ToString());
            double slmoi = sl - Convert.ToDouble(txtSoluong.Text);

            sql = "update tblHang set Soluongtonkho=" + slmoi + " where Mahang=N'" + cboMahang.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            ResetValuesHang();
            btnHuy.Enabled = true;
        }
예제 #11
0
        private void frmKhachhang_Load(object sender, EventArgs e)
        {
            btnThem.Enabled      = true;
            btnLuu.Enabled       = false;
            btnHuy.Enabled       = false;
            btnXoa.Enabled       = false;
            txtMaKH.ReadOnly     = true;
            grbKhachhang.Enabled = false;
            string sql = "SELECT * FROM tblKhachhang";

            tblKH = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblKH;
            Hienthi_Luoi();
        }
예제 #12
0
        private void cboMahang_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboMahang.Text == "")
            {
                txtTenhang.Text = "";
                return;
            }
            DataTable table = ThucthiSQL.DocBang("select Tenhang from tblHang where Mahang=N'" + cboMahang.Text + "'");

            if (table.Rows.Count > 0)
            {
                txtTenhang.Text = table.Rows[0][0].ToString();
            }
        }
예제 #13
0
        private void frmChucvu_Load(object sender, EventArgs e)
        {
            btnThem.Enabled   = true;
            btnLuu.Enabled    = false;
            btnHuy.Enabled    = false;
            btnXoa.Enabled    = false;
            grbChucvu.Enabled = false;
            string sql;

            sql   = "SELECT * FROM tblChucvu";
            tblCV = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblCV;
            Hienthi_Luoi();
        }
예제 #14
0
        private void frmNCC_Load(object sender, EventArgs e)
        {
            btnThem.Enabled       = true;
            btnLuu.Enabled        = false;
            btnHuy.Enabled        = false;
            btnXoa.Enabled        = false;
            txtMaNCC.ReadOnly     = true;
            grbNhacungcap.Enabled = false;
            string sql = "SELECT * FROM tblNCC";

            tblNCC = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblNCC;
            Hienthi_Luoi();
        }
예제 #15
0
        private void cboManhanvien_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboManhanvien.Text == "")
            {
                txtTennhanvien.Text = "";
                return;
            }
            string    sql   = "select TenNV from tblNhanvien where MaNV=N'" + cboManhanvien.Text + "'";
            DataTable table = ThucthiSQL.DocBang(sql);

            if (table.Rows.Count > 0)
            {
                txtTennhanvien.Text = table.Rows[0][0].ToString();
            }
        }
예제 #16
0
        private void btnTimkiem_Click(object sender, EventArgs e)
        {
            string sql = "SELECT * from tblKhachhang where TenKH Like N'%" + txtTimkiem.Text + "%' or Diachi Like N'%" + txtTimkiem.Text + "%' or SDT Like N'%" + txtTimkiem.Text + "%'or MaKH Like N'%" + txtTimkiem.Text + "%'";

            tblKH = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblKH;
            Hienthi_Luoi();
            if (tblKH.Rows.Count == 0)
            {
                MessageBox.Show("Không có bản ghi thỏa mãn điều kiện!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Có " + tblKH.Rows.Count + " bản ghi thỏa mãn điều kiện!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #17
0
        private void cboMaNV_TextChanged(object sender, EventArgs e)
        {
            string sql;

            if (cboMaNV.Text == "")
            {
                txtTenNV.Text = "";
                return;
            }
            sql = " SELECT TenNV FROM tblNhan_vien WHERE MaNV=N'" + cboMaNV.Text + "'";
            DataTable table = ThucthiSQL.DocBang(sql);

            if (table.Rows.Count > 0)
            {
                txtTenNV.Text = table.Rows[0][0].ToString();
            }
        }
예제 #18
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtTenKH.Text == "")
            {
                MessageBox.Show("Bạn phải nhập tên khách hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenKH.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachi.Focus();
                return;
            }
            if (txtSDT.Text == "")
            {
                MessageBox.Show("Bạn phải nhập số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSDT.Focus();
                return;
            }
            sql   = "select * from tblKhachhang where MaKH = N'" + txtMaKH.Text + "'";
            tblKH = ThucthiSQL.DocBang(sql);
            if (tblKH.Rows.Count == 0)
            {
                sql = "INSERT INTO tblKhachhang(MaKH, TenKH, Diachi, SDT) Values (N'" + txtMaKH.Text +
                      "',N'" + txtTenKH.Text + "',N'" + txtDiachi.Text + "',N'" + txtSDT.Text + "')";
            }
            else
            {
                sql = "UPDATE tblKhachhang SET TenKH = N'" + txtTenKH.Text + "', Diachi = N'" + txtDiachi.Text + "', SDT = N'" + txtSDT.Text + "' WHERE MaKH = N'" + txtMaKH.Text + "'";
            }

            ThucthiSQL.CapNhatDuLieu(sql);
            btnThem.Enabled = true;
            btnLuu.Enabled  = false;
            btnHuy.Enabled  = false;
            btnXoa.Enabled  = false;
            ResetValues();
            sql   = "SELECT * FROM tblKhachhang";
            tblKH = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblKH;
            Hienthi_Luoi();
            grbKhachhang.Enabled = false;
        }
예제 #19
0
        private void cboMaKH_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboMaKH.Text == "")
            {
                txtTenkhachhang.Text = "";
                txtSDT.Text          = "";
                txtDiachi.Text       = "";
                return;
            }
            DataTable table = ThucthiSQL.DocBang("select TenKH, Diachi, SDT from tblKhachhang where MaKH=N'" + cboMaKH.Text + "'");

            if (table.Rows.Count > 0)
            {
                txtTenkhachhang.Text = table.Rows[0][0].ToString();
                txtDiachi.Text       = table.Rows[0][1].ToString();
                txtSDT.Text          = table.Rows[0][2].ToString();
            }
        }
예제 #20
0
        private void Hienthi_Luoi()
        {
            string sql;

            sql = "SELECT Ma_mayVT,So_luong,Don_gia,Thanh_tien FROM tblChitietHDN WHERE Ma_HDN = N'" +
                  txtMahoadon.Text + "'";
            dataGridView_HDN.DataSource            = ThucthiSQL.DocBang(sql);
            dataGridView_HDN.Columns[0].HeaderText = "Mã máy tính";
            dataGridView_HDN.Columns[1].HeaderText = "Số lượng ";
            dataGridView_HDN.Columns[2].HeaderText = "Đơn giá";
            dataGridView_HDN.Columns[3].HeaderText = "Thành tiền";
            dataGridView_HDN.Columns[0].Width      = 80;
            dataGridView_HDN.Columns[1].Width      = 130;
            dataGridView_HDN.Columns[2].Width      = 80;
            dataGridView_HDN.Columns[3].Width      = 90;
            dataGridView_HDN.AllowUserToAddRows    = false;
            dataGridView_HDN.EditMode = DataGridViewEditMode.EditProgrammatically;
        }
예제 #21
0
        private void DelUpdateHang(string mahang, double slxoa, double gianhapxoa)
        {
            double sl = Convert.ToDouble(ThucthiSQL.DocBang("select Soluongtonkho from tblHang where Mahang=N'" +
                                                            mahang + "'").Rows[0][0].ToString());
            double slmoi = sl - slxoa;
            string sql   = "update tblHang set Soluongtonkho=" + slmoi + "where Mahang=N'" + mahang + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
            double dgn    = Convert.ToDouble(ThucthiSQL.DocBang("select Dongianhap from tblHang where Mahang=N'" + mahang + "'").Rows[0][0].ToString());
            double dgnmoi = (sl * dgn - slxoa * gianhapxoa) / slmoi;

            sql = "update tblHang set Dongianhap=" + dgnmoi + "where Mahang = N'" + cboMahang.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            double dgbmoi = dgnmoi + dgnmoi * 0.2;

            sql = "update tblHang set Dongiaban=" + dgbmoi + "where Mahang = N'" + cboMahang.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
        }
예제 #22
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            string sql;

            if (MessageBox.Show("Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                sql = "DELETE FROM tblKhachhang WHERE MaKH=N'" + txtMaKH.Text + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                sql   = "SELECT * FROM tblKhachhang";
                tblKH = ThucthiSQL.DocBang(sql);
                dataGridView.DataSource = tblKH;
                Hienthi_Luoi();
                ResetValues();
                grbKhachhang.Enabled = false;
                btnHuy.Enabled       = false;
                btnLuu.Enabled       = false;
            }
        }
예제 #23
0
        private void cboMamayvitinh_TextChanged(object sender, EventArgs e)
        {
            string sql;

            if (cboMamayvitinh.Text == "")
            {
                txtTenmaytinh.Text = "";
                txtDon_gia.Text    = "";
                return;
            }
            sql = " SELECT Ten_mayVT,Gia_nhap FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" + cboMamayvitinh.Text + "'";
            DataTable table = ThucthiSQL.DocBang(sql);

            if (table.Rows.Count > 0)
            {
                txtTenmaytinh.Text = table.Rows[0][0].ToString();
                txtDon_gia.Text    = table.Rows[0][1].ToString();
            }
        }
예제 #24
0
        private void cboMaNCC_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboMaNCC.Text == "")
            {
                txtTenNCC.Text    = "";
                txtDiachi.Text    = "";
                txtDienthoai.Text = "";
                return;
            }
            string    sql   = "select TenNCC, Diachi, SDT from tblNCC where MaNCC=N'" + cboMaNCC.Text + "'";
            DataTable table = ThucthiSQL.DocBang(sql);

            if (table.Rows.Count > 0)
            {
                txtTenNCC.Text    = table.Rows[0][0].ToString();
                txtDiachi.Text    = table.Rows[0][1].ToString();
                txtDienthoai.Text = table.Rows[0][2].ToString();
            }
        }
예제 #25
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql = "SELECT * FROM tblNCC where MaNCC = N'" + txtMaNCC.Text + "'";

            if (txtTenNCC.Text == "")
            {
                MessageBox.Show("Bạn phải nhập tên nhà cung cấp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenNCC.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachi.Focus();
                return;
            }
            if (txtSDT.Text == "")
            {
                MessageBox.Show("Bạn phải nhập số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSDT.Focus();
                return;
            }
            tblNCC = ThucthiSQL.DocBang(sql);
            if (tblNCC.Rows.Count == 0)
            {
                sql = "INSERT INTO tblNCC(MaNCC, TenNCC, Diachi, SDT) Values (N'" + txtMaNCC.Text +
                      "',N'" + txtTenNCC.Text + "',N'" + txtDiachi.Text + "',N'" + txtSDT.Text + "')";
            }
            else
            {
                sql = "UPDATE tblNCC SET TenNCC = N'" + txtTenNCC.Text + "', Diachi = N'" + txtDiachi.Text + "', SDT = N'" + txtSDT.Text + "' where MaNCC = N'" + txtMaNCC.Text + "'";
            }
            ThucthiSQL.CapNhatDuLieu(sql);
            btnThem.Enabled = true;
            btnLuu.Enabled  = false;
            btnHuy.Enabled  = false;
            btnXoa.Enabled  = false;
            ResetValues();
            sql    = "SELECT * FROM tblNCC";
            tblNCC = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblNCC;
            Hienthi_Luoi();
        }
        private void Hienthi_Luoi()
        {
            string    sql;
            DataTable tblMT;

            sql   = "SELECT Ma_mayVT,Ten_mayVT,Ma_hang_SX,Ma_loai_may,Ma_RAM,Ma_chip,Ma_MH,Ma_co_MH,Ma_o_Cung,Ma_dungluong,Ma_chuot,Ma_ban_phim,So_luong,Gia_nhap,Gia_ban FROM  dboMay_vi_tinh";
            tblMT = ThucthiSQL.DocBang(sql);
            DataGridView.DataSource             = tblMT;
            DataGridView.Columns[0].HeaderText  = "Mã Máy Tính";
            DataGridView.Columns[1].HeaderText  = "Tên Máy Tính";
            DataGridView.Columns[2].HeaderText  = "Hãng Sản Xuất";
            DataGridView.Columns[3].HeaderText  = "Mã Loại Máy";
            DataGridView.Columns[4].HeaderText  = "RAM";
            DataGridView.Columns[5].HeaderText  = "Chip";
            DataGridView.Columns[6].HeaderText  = "Màn hình";
            DataGridView.Columns[7].HeaderText  = "Kích cỡ";
            DataGridView.Columns[8].HeaderText  = "Loại ổ cứng";
            DataGridView.Columns[9].HeaderText  = "Dung Lượng";
            DataGridView.Columns[10].HeaderText = "Chuột";
            DataGridView.Columns[11].HeaderText = "Bàn Phím";
            DataGridView.Columns[12].HeaderText = "Số Lượng";
            DataGridView.Columns[13].HeaderText = "Giá Nhập";
            DataGridView.Columns[14].HeaderText = "Giá Bán";
            DataGridView.Columns[0].Width       = 50;
            DataGridView.Columns[1].Width       = 120;
            DataGridView.Columns[2].Width       = 100;
            DataGridView.Columns[3].Width       = 50;
            DataGridView.Columns[4].Width       = 50;
            DataGridView.Columns[5].Width       = 70;
            DataGridView.Columns[6].Width       = 60;
            DataGridView.Columns[7].Width       = 60;
            DataGridView.Columns[8].Width       = 60;
            DataGridView.Columns[9].Width       = 60;
            DataGridView.Columns[10].Width      = 100;
            DataGridView.Columns[11].Width      = 100;
            DataGridView.Columns[12].Width      = 40;
            DataGridView.Columns[13].Width      = 70;
            DataGridView.Columns[14].Width      = 70;
            DataGridView.AllowUserToAddRows     = false;
            DataGridView.EditMode = DataGridViewEditMode.EditProgrammatically;
            tblMT.Dispose();
        }
예제 #27
0
 private void btnHuy_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn hủy hóa đơn không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         string    sql = "SELECT Ma_HDB, So_luong, Ma_mayVT FROM tblChitietHDB WHERE Ma_HDB = N'" + txtMa_HDB.Text + "'";
         DataTable tbl = ThucthiSQL.DocBang(sql);
         sql = "DELETE tblHDB WHERE Ma_HDB = N'" + txtMa_HDB.Text + "'";
         ThucthiSQL.CapNhatDuLieu(sql);
         ResetValues();
         Hienthi_Luoi();
         // cập nhật lại số lượng máy tính
         for (int i = 0; i < tbl.Rows.Count; i++)
         {
             DelUpdateSo_luongMVT(tbl.Rows[i][0].ToString(),
                                  Convert.ToDouble(tbl.Rows[0][1]),
                                  Convert.ToDouble(tbl.Rows[0][2]));
         }
         btnHuy.Enabled = false;
     }
 }
예제 #28
0
        public void Hienthi_Luoi()
        {
            string sql = "Select * from tblChitietHDN where MaHDN=N'" + txtMahoadon.Text + "'";

            dataGridView.DataSource            = ThucthiSQL.DocBang(sql);
            dataGridView.Columns[0].HeaderText = "Mã hàng";
            dataGridView.Columns[1].HeaderText = "Mã Hóa đơn nhập";
            dataGridView.Columns[2].HeaderText = "Số lượng";
            dataGridView.Columns[3].HeaderText = "Giá nhập";
            dataGridView.Columns[4].HeaderText = "Giảm giá";
            dataGridView.Columns[5].HeaderText = "Thành tiền";
            dataGridView.Columns[0].Width      = 50;
            dataGridView.Columns[1].Width      = 100;
            dataGridView.Columns[2].Width      = 50;
            dataGridView.Columns[3].Width      = 100;
            dataGridView.Columns[4].Width      = 100;
            dataGridView.Columns[5].Width      = 100;
            dataGridView.AllowUserToAddRows    = false;
            dataGridView.EditMode = DataGridViewEditMode.EditProgrammatically;
        }
예제 #29
0
 private void btnHuy_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc chắn muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         string    sql = "select Mahang, Soluong, Gianhap from tblchitietHDN where MaHDN=N'" + txtMahoadon.Text + "'";
         DataTable tbl = ThucthiSQL.DocBang(sql);
         sql = "delete tblHoadonnhap where MaHDN=N'" + txtMahoadon.Text + "'";
         ThucthiSQL.CapNhatDuLieu(sql);
         ResetValues();
         Hienthi_Luoi();
         for (int i = 0; i < tbl.Rows.Count; i++)
         {
             DelUpdateHang(tbl.Rows[0][0].ToString(), Convert.ToDouble(tbl.Rows[i][1].ToString()), Convert.ToDouble(tbl.Rows[i][2].ToString()));
         }
         btnHuy.Enabled           = false;
         btnIn.Enabled            = false;
         grbThongtinphieu.Enabled = false;
         grbChitiet.Enabled       = false;
     }
 }
예제 #30
0
파일: frmHang.cs 프로젝트: ThanhSarah/TTCN2
        private void frmHang_Load(object sender, EventArgs e)
        {
            btnThem.Enabled         = true;
            btnLuu.Enabled          = false;
            btnHuy.Enabled          = false;
            btnXoa.Enabled          = false;
            txtDongiaban.ReadOnly   = true;
            txtDongianhap.ReadOnly  = true;
            txtSoluong.ReadOnly     = true;
            txtDongiaban.Text       = "0";
            txtDongianhap.Text      = "0";
            txtSoluong.Text         = "0";
            txtMaHH.ReadOnly        = true;
            grbThongtinhang.Enabled = false;
            string sql = "SELECT * FROM tblHang";

            tblH = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblH;
            Hienthi_Luoi();
        }