private void NVKT_Load(object sender, EventArgs e) { //cn = new SqlConnection(@"Data Source=DESKTOP-2LMHPI9\SQLEXPRESS; Initial Catalog=QL_INTERNET1; Integrated Security=True;"); cn.Open(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string sele = "Select nv.Manv, Tennv, gioitinh, luong, tencv, DiaChiNV, sdtnv, ngaysinh from Nhanvien nv, Chucvu cv where SDTnv = '" + sdt + "' and nv.Macv = cv.Macv"; //string sele = "Select nv.Manv, Tennv, gioitinh, luong, tencv, diachi, sdt, ngaysinh from Nhanvien nv, Chucvu cv where SDT = '0927352718' and nv.Macv = cv.Macv"; SqlCommand cm = new SqlCommand(sele, cn); SqlDataReader rd = cm.ExecuteReader(); while (rd.Read()) { label1.Text = "Chào " + rd["Tennv"].ToString() + ","; label2.Text = label2.Text + " " + rd["Manv"].ToString(); label9.Text = label9.Text + " " + rd["Tennv"].ToString(); label3.Text = label3.Text + " " + rd["gioitinh"].ToString(); label4.Text = label4.Text + " " + rd["luong"].ToString(); label7.Text = label7.Text + " " + rd["tencv"].ToString(); label6.Text = label6.Text + " " + rd["diachinv"].ToString(); label8.Text = label8.Text + " " + rd["sdtnv"].ToString(); label5.Text = label5.Text + " " + rd["ngaysinh"].ToString(); } cn.Close(); cn.Open(); sele = "Select * from hotro where manv = '" + label2.Text.Substring(7) + "'"; SqlDataAdapter da = new SqlDataAdapter(sele, cn); DataSet ds = new DataSet(); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; cn.Close(); }
private void NVTD_Load(object sender, EventArgs e) { //cn = new SqlConnection(@"Data Source=DESKTOP-2LMHPI9\SQLEXPRESS; Initial Catalog=QL_INTERNET1; Integrated Security=True;"); cn.Open(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string sele = "Select nv.Manv, Tennv, gioitinh, luong, tencv, diachinv, sdtnv, ngaysinh from Nhanvien nv, Chucvu cv where SDTnv = '" + sdt + "' and nv.Macv = cv.Macv"; //string sele = "Select nv.Manv, Tennv, gioitinh, luong, tencv, diachi, sdt, ngaysinh from Nhanvien nv, Chucvu cv where SDT = '0856218771' and nv.Macv = cv.Macv"; SqlCommand cm = new SqlCommand(sele, cn); SqlDataReader rd = cm.ExecuteReader(); while (rd.Read()) { label1.Text = "Chào " + rd["Tennv"].ToString() + ","; label2.Text = label2.Text + " " + rd["Manv"].ToString(); label9.Text = label9.Text + " " + rd["Tennv"].ToString(); label3.Text = label3.Text + " " + rd["gioitinh"].ToString(); label4.Text = label4.Text + " " + rd["luong"].ToString(); label7.Text = label7.Text + " " + rd["tencv"].ToString(); label6.Text = label6.Text + " " + rd["diachinv"].ToString(); label8.Text = label8.Text + " " + rd["sdtnv"].ToString(); label5.Text = label5.Text + " " + rd["ngaysinh"].ToString(); } cn.Close(); }
public void load_hoadon() { DataSet ds = new DataSet(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); SqlDataAdapter da = new SqlDataAdapter("select HOADON.MaHD, MaGC, DonGia, GiamGia, ThanhTien,HOADON.NgayLapHD,trangthai from HOADON ,CTHD where HOADON.mahd= CTHD.mahd and HOADON.makh = (select makh from KHACHHANG where sdt='" + sdt + "')", connsql); //dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; DataTable tb = new DataTable(); da.Fill(tb); dataGridView1.DataSource = tb; }
void load_NV() { connsql.Open(); DataSet ds = new DataSet(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); SqlDataAdapter da = new SqlDataAdapter("SELECT *FROM Nhanvien", connsql); //dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; DataTable tb = new DataTable(); da.Fill(tb); dataGridView2.DataSource = tb; connsql.Close(); }
void load_manv() { connsql.Open(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string sel = "SELECT manv FROM Nhanvien where sdtnv='" + sdt + "'"; SqlCommand cm = new SqlCommand(sel, connsql); SqlDataReader rd = cm.ExecuteReader(); rd.Read(); txtnvhd.Text = rd["manv"].ToString(); txtnvhd.Enabled = false; connsql.Close(); }
public void load_loc() { DataSet ds = new DataSet(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string str = "select mahd,trangthai from hoadon where makh=(select makh from KHACHHANG where sdt='" + sdt + "')"; SqlDataAdapter da = new SqlDataAdapter(str, connsql); da.Fill(ds, "HOADON"); comboBox1.DataSource = ds.Tables[0]; comboBox1.DisplayMember = "trangthai"; comboBox1.ValueMember = "trangthai"; comboBox1.SelectedIndex = 0; }
private void bt_capnhat_Click(object sender, EventArgs e) { dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); connsql.Open(); string updateString = "update Khachhang set TENkh= N'" + textBox1.Text.ToString() + "',DIaCHI=N'" + textBox2.Text.ToString() + "' where SDT= '" + sdt + "'"; SqlCommand cmd = new SqlCommand(updateString, connsql); cmd.ExecuteNonQuery(); connsql.Close(); MessageBox.Show("Cập nhật thành công"); }
void load_wf() { connsql.Open(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string sel = "select khachhang.makh,taikhoanwifi,matkhauwifi from wifi,KHACHHANG where KHACHHANG.MaKH=wifi.MaKH and KHACHHANG.SDT='" + sdt + "'"; SqlCommand cmd = new SqlCommand(sel, connsql); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { label5.Text = (rd["makh"].ToString().Trim()); label6.Text = (rd["taikhoanwifi"].ToString().Trim()); label7.Text = (rd["matkhauwifi"].ToString().Trim()); } connsql.Close(); }
public void load_ttgc() { connsql.Open(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string sel = "select GoiCuoc.TenGC,GoiCuoc.MaGC from HOADON ,CTHD,GoiCuoc where HOADON.mahd= CTHD.mahd and GoiCuoc.MAGC=CTHD.MAGC and HOADON.makh = (select makh from KHACHHANG where sdt='" + sdt + "')"; SqlCommand cm = new SqlCommand(sel, connsql); SqlDataReader rd = cm.ExecuteReader(); while (rd.Read()) { label1_tengoi.Text = rd["TenGC"].ToString(); label_magoi.Text = rd["MAGC"].ToString(); } connsql.Close(); }
private void button1_Click(object sender, EventArgs e) { { connsql.Open(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string updateString = "update wifi set taikhoanwifi=N'" + txtten.Text.ToString() + "',matkhauwifi=N'" + txtmk.Text.ToString() + "' from wifi,KHACHHANG where wifi.MaKH = KHACHHANG.MaKH and KHACHHANG.SDT = '" + sdt + "'"; SqlCommand cmd = new SqlCommand(updateString, connsql); cmd.ExecuteNonQuery(); connsql.Close(); MessageBox.Show("Cập nhật thành công"); } load_wf(); }
private void NVTC_Load(object sender, EventArgs e) { //cn = new SqlConnection(@"Data Source=DESKTOP-2LMHPI9\SQLEXPRESS; Initial Catalog=QL_INTERNET1; Integrated Security=True;"); //cn = new SqlConnection(@"Data Source=TOSHIBA-SATELLI; Initial Catalog=QL_INTERNET1; Integrated Security=True;"); cn.Open(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string sele = "Select nv.Manv, Tennv, gioitinh, luong, tencv, diachinv, sdtnv, ngaysinh from Nhanvien nv, Chucvu cv where SDTnv = '" + sdt + "' and nv.Macv = cv.Macv"; //string sele = "Select nv.Manv, Tennv, gioitinh, luong, tencv, diachinv, sdtnv, ngaysinh from Nhanvien nv, Chucvu cv where SDTnv = '0919395758' and nv.Macv = cv.Macv"; SqlCommand cm = new SqlCommand(sele, cn); SqlDataReader rd = cm.ExecuteReader(); while (rd.Read()) { label1.Text = "Chào " + rd["Tennv"].ToString() + ","; label2.Text = label2.Text + " " + rd["Manv"].ToString(); label9.Text = label9.Text + " " + rd["Tennv"].ToString(); label3.Text = label3.Text + " " + rd["gioitinh"].ToString(); label4.Text = label4.Text + " " + rd["luong"].ToString(); label7.Text = label7.Text + " " + rd["tencv"].ToString(); label6.Text = label6.Text + " " + rd["diachinv"].ToString(); label8.Text = label8.Text + " " + rd["sdtnv"].ToString(); label5.Text = label5.Text + " " + rd["ngaysinh"].ToString(); } cn.Close(); //richTextBox1.Text = "Đây là một tính năng."; cboTrangthai.SelectedIndex = 0; cn.Open(); sele = ""; sele = sele + "Select kh.makh 'Mã khách hàng', tenkh 'Họ tên', sdt 'SĐT', diachi 'Địa chỉ', ngayhen 'Ngày hẹn', cthd.magc 'Gói cước', thanhtien 'Thành tiền', ht.trangthai 'Trạng thái', yeucau 'Yêu cầu' "; sele = sele + "from hotro ht, khachhang kh, hoadon hd, cthd "; sele = sele + "where ht.makh = kh.makh and kh.makh = hd.makh and hd.mahd = cthd.mahd and ht.manv = '" + label2.Text.Substring(7) + "'"; //1 hỗ trợ thu cước có 1 khách hàng 1 hóa đơn 1 nv hỗ trợ + lập hóa đơn; Hoadon, Chitiethoadon quan hệ 1-1 SqlDataAdapter da = new SqlDataAdapter(sele, cn); DataSet ds = new DataSet(); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; cn.Close(); }
public void load_ttKH() { connsql.Open(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string sel = "select MAKH, TENKH, DiaChi, SDT from khachhang where SDT='" + sdt + "'"; SqlCommand cm = new SqlCommand(sel, connsql); SqlDataReader rd = cm.ExecuteReader(); while (rd.Read()) { label_mak.Text = rd["makh"].ToString(); label_tenkh.Text = rd["TenKH"].ToString(); label_diachi.Text = rd["DiaCHi"].ToString(); label_sdt.Text = rd["SDT"].ToString(); } connsql.Close(); }
void load_KH() { connsql.Open(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string sel = "SELECT *FROM KHACHHANG where makh='" + txtkhhd.Text.ToString() + "'"; SqlCommand cm = new SqlCommand(sel, connsql); SqlDataReader rd = cm.ExecuteReader(); while (rd.Read()) { txttenkhhd.Text = rd["tenkh"].ToString(); txttenkhhd.Enabled = false; txtdiackh.Text = rd["diachi"].ToString(); txtdiackh.Enabled = false; txtsdtkh.Text = rd["SDT"].ToString(); txtsdtkh.Enabled = false; } connsql.Close(); }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.Text.ToString() == "Chọn trạng thái") { MessageBox.Show("vui lòng chọn trạng thái trước khi lọc dữ liệu"); load_hoadon(); } else { load_hoadon(); dataGridView1.Controls.Clear(); DataSet ds = new DataSet(); dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); SqlDataAdapter da = new SqlDataAdapter("select HOADON.MaHD, MaGC, DonGia, GiamGia, ThanhTien,HOADON.NgayLapHD,trangthai from HOADON ,CTHD where HOADON.mahd= CTHD.mahd and trangthai=N'" + comboBox1.SelectedValue + "' and HOADON.makh = (select makh from KHACHHANG where sdt='" + sdt + "')", connsql); //dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; DataTable tb1 = new DataTable(); da.Fill(tb1); dataGridView1.DataSource = tb1; } }
public bool KT_tt() { dangnhap dn = new dangnhap(); string sdt = dn.gan_sdt(); string selectString = "select trangthai from hoadon where trangthai='Đã thanh toán' and makh=(select makh from KHACHHANG where sdt='" + sdt + "')"; connsql.Open(); SqlCommand cmd = new SqlCommand(selectString, connsql); SqlDataReader rd = cmd.ExecuteReader(); if (rd.HasRows) { rd.Close(); connsql.Close(); return(true); } else { rd.Close(); connsql.Close(); return(false); } }