private void them(object sender, EventArgs e) { try { string sql = "insert into SanPham Values('" + tbxMaSP.Text + "',N'" + tbxTenSP.Text + "','" + tbxMaLSP.Text + "','" + tbxMaHSX.Text + "','" + tbxGiaBan.Text + "',N'" + tbxBaoHanh.Text + "',N'" + tbxTinhNang.Text + "')"; acc.excuteNonQuery(sql); MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); // dataGridView1.Refresh(); SanPham_Load(sender, e); } catch (Exception) { MessageBox.Show("error"); } }
private void btnXoa_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(@" Data Source=DESKTOP-H1LP27V;Initial Catalog=QuanLyKhoHang;Integrated Security=True"); accessData acc = new accessData(); string sql = "delete from SanPham where MaSP='" + tbxMaSP.Text + "'"; acc.excuteNonQuery(sql); try { tbxMaSP.Clear(); tbxTenSP.Clear(); tbxMaLSP.Clear(); tbxMaHSX.Clear(); tbxGiaBan.Clear(); tbxBaoHanh.Clear(); tbxTinhNang.Clear(); } catch { } MessageBox.Show("Xoá thành công !"); SanPham_Load(sender, e); }
private void ThemPN(object sender, EventArgs e) { try { string sql = "insert into PhieuNhap Values(N'" + tbxMaPN.Text + "','" + tbxMaSP.Text + "','" + tbxMaHSX.Text + "','" + tbxMaNV.Text + "','" + dtNgayNhap.Text + "',N'" + tbxSoLuong.Text + "',N'" + tbxDonGia.Text + "')"; acc.excuteNonQuery(sql); MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); CTPhieuNhap_Load(sender, e); } catch (Exception) { MessageBox.Show("error"); } }
private void ThemNV(object sender, EventArgs e) { try { string sql = "insert into NhanVien Values('" + tbxMaNV.Text + "','" + tbxHoTen.Text + "','" + dtNgaySinh.Text + "','" + cbxGioiTinh.Text + "','" + tbxDiaChi.Text + "','" + tbxSoDienThoai.Text + "')"; acc.excuteNonQuery(sql); MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); NhanVien_Load(sender, e); } catch (Exception) { MessageBox.Show("error"); } }
private void ThemLoaiSP(object sender, EventArgs e) { try { string sql = "insert into LoaiSP Values('" + tbxMaLSP.Text + "',N'" + tbxTenLSP.Text + "')"; acc.excuteNonQuery(sql); MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoaiSP_Load(sender, e); } catch (Exception) { MessageBox.Show("error"); } }
private void ThemSPTonKho(object sender, EventArgs e) { try { string sql = "insert into TonKho Values(N'" + tbxMaSP.Text + "','" + tbxMaHSX.Text + "','" + tbxSoLuong.Text + "')"; acc.excuteNonQuery(sql); MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); TonKho_Load(sender, e); } catch (Exception) { MessageBox.Show("error"); } }
private void themPBH(object sender, EventArgs e) { try { string sql = "insert into PhieuBH Values(N'" + tbxMaPBH.Text + "','" + tbxMaSP.Text + "','" + tbxMaNV.Text + "','" + dtNgayLap.Text + "',N'" + tbxTGBH.Text + "')"; acc.excuteNonQuery(sql); MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); CTPhieuBH_Load(sender, e); } catch (Exception) { MessageBox.Show("error"); } }
private void ThemHSX(object sender, EventArgs e) { try { string sql = "insert into HangSX Values('" + tbxMaHSX.Text + "',N'" + tbxTenHSX.Text + "',N'" + tbxDiaChi.Text + "')"; acc.excuteNonQuery(sql); MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); HangSanXuat_Load(sender, e); } catch (Exception) { MessageBox.Show("error"); } }
private void btnXoa_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(@" Data Source=DESKTOP-H1LP27V;Initial Catalog=QuanLyKhoHang;Integrated Security=True"); accessData acc = new accessData(); string sql = "delete from NhanVien where MaSP='" + tbxMaNV.Text + "'"; acc.excuteNonQuery(sql); try { tbxMaNV.Clear(); tbxHoTen.Clear(); //tbxNgaySinh.Clear(); //tbxGioiTinh.Clear(); tbxDiaChi.Clear(); tbxSoDienThoai.Clear(); } catch { } MessageBox.Show("Xoá thành công !"); try { tbxMaNV.Clear(); tbxHoTen.Clear(); // dtNgaySinh.Clear(); // cbxGioiTinh.Clear(); tbxDiaChi.Clear(); tbxSoDienThoai.Clear(); } catch { } MessageBox.Show("Xoá thành công !"); }
private void TonKho_Load(object sender, EventArgs e) { string sql1 = "CapNhat"; string sql2 = "sp_TonKho"; string sql3 = "sp_Nhap"; string sql4 = "sp_Xuat"; try { if (acc.excuteNonQuery(sql1) == true) { DataTable ds1 = new DataTable(); DataTable ds2 = new DataTable(); DataTable ds3 = new DataTable(); SqlDataAdapter dap1 = acc.executeDatatable(sql2); SqlDataAdapter dap2 = acc.executeDatatable(sql3); SqlDataAdapter dap3 = acc.executeDatatable(sql4); dap1.Fill(ds1); dgvTonKho.DataSource = ds1; dgvTonKho.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dap2.Fill(ds2); dgvNhapHang.DataSource = ds2; dgvNhapHang.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dap3.Fill(ds3); dgvHangXuat.DataSource = ds3; dgvHangXuat.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; txtTong1.Text = acc.executeScalar("select sum(a.Soluong) from SanPham a").ToString(); txtTong2.Text = acc.executeScalar("select sum(a.Soluong) from PhieuNhap a").ToString(); txtTong3.Text = acc.executeScalar("select sum(a.Soluong) from PhieuXuat a").ToString(); txtTien1.Text = ds1.Compute("Sum([Tổng giá])", "").ToString(); txtTien2.Text = ds2.Compute("Sum([Tổng giá])", "").ToString(); txtTien3.Text = ds3.Compute("Sum([Tổng giá])", "").ToString(); } } catch { MessageBox.Show("cap nhat khong thanh cong", "bao loi"); } }
private void btnXoa_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(@" Data Source=DESKTOP-H1LP27V;Initial Catalog=QuanLyKhoHang;Integrated Security=True"); accessData acc = new accessData(); string sql = "delete from PhieuNhap where MaPN='" + tbxMaPN.Text + "'"; acc.excuteNonQuery(sql); try { tbxMaPN.Clear(); tbxMaSP.Clear(); tbxMaHSX.Clear(); tbxMaNV.Clear(); tbxNgayNhap.Clear(); tbxSoLuong.Clear(); tbxDonGia.Clear(); } catch { } MessageBox.Show("Xoá thành công !"); }