private void button3_Click(object sender, EventArgs e) { string idsp = txtid.Text.Trim(); bool check = database.Check(idsp, "select SanPhamID from SanPham "); if (check == false) { if (txtid.Text == "") { MessageBox.Show("Chưa có thông tin để thêm"); } else { //command = connection.CreateCommand(); string insert = "insert into SanPham values(N'" + txtid.Text + "',N'" + txtncc.Text + "',N'" + txtten.Text + "',N'" + txthang.Text + "',N'" + txtxuatxu.Text + "',N'" + txtmau.Text + "'," + txtsl.Text + "," + txtgia.Text + ",'" + txtdate.Text + "',N'" + txtbaohanh.Text + "')"; //command.ExecuteNonQuery(); database.SQLConnection(insert); //LoadDataAll(); database.LoadDataGridView(DanhMuc, "select * from dbo.SanPham"); MessageBox.Show("Thêm sản Phẩm thành công !"); } } else { MessageBox.Show("sản phẩm này đã tồn tại"); } }
private void buttonDangNhap_Click(object sender, EventArgs e) { if (textBoxUsername.Text.TrimEnd().Length != 0 && textBoxPassword.Text.TrimEnd().Length != 0) { string username = textBoxUsername.Text.TrimEnd(); string password = textBoxPassword.Text.TrimEnd(); bool check = database.Check(password, "SELECT MatKhau FROM dbo.TaiKhoan WHERE Username='******'"); if (check == true) { useraccount = username; FormMain m = new FormMain(); m.Show(); this.Hide(); } else { MessageBox.Show("Username hoặc password không chính xác!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBoxUsername.Text = ""; textBoxPassword.Text = ""; checkBoxShow.Checked = false; } } else { MessageBox.Show("Vui lòng nhập đầy đủ username và password!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); textBoxUsername.Text = ""; textBoxPassword.Text = ""; checkBoxShow.Checked = false; } }
private void cbbMaNV_SelectedIndexChanged(object sender, EventArgs e) { string temp = cbbMaNV.SelectedItem.ToString(); database.loadTextBox(txtTenNV, "select HoTenNV from NHANVIEN where MaNV = N'" + temp + "'"); bool check = database.Check(temp, "select MaNV from TAIKHOAN"); if (check == true) { database.loadTextBox(txttendn, "select TenDangNhap from TAIKHOAN where MaNV = N'" + temp + "'"); database.loadTextBox(txtpass, "select MatKhau from TAIKHOAN where MaNV = N'" + temp + "'"); database.loadComboBox_Show(comboBoxquyen, "select q.TenQuyen from QUYEN q, TAIKHOAN tk where q.MaQuyen=tk.MaQuyen and tk.MaNV = N'" + temp + "'"); } else { Reset(); } }
private void button1_Click(object sender, EventArgs e) { string tenn = txtten.Text.Trim(); string sdtt = txtsdt.Text.Trim(); string cmndd = cbbCmnd.Text.Trim(); try { bool check = database.Check(cmndd, "Select CMND from KHACHHANG"); if (check == false) { if (tenn.Length != 0 && sdtt.Length != 0 && cmndd.Length != 0) { if ((cmndd.Length == 9 || cmndd.Length == 12)) { string insert = " Insert into KHACHHANG values( N'" + tenn + "',N'" + cmndd + "',N'" + sdtt + "')"; database.ThucThiKetNoi(insert); MessageBox.Show("Hoàn Tất!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); MAKH.Text = "Mã KH :"; database.loadlabel(showma, "select MaKH from KHACHHANG where CMND = N'" + cmndd + "'"); database.loadDataGridView(dgv, "select * from KHACHHANG where CMND = N'" + cmndd + "' "); Rerset(); Loadcmnd(); } else { MessageBox.Show("CMND 9 hoặc 12 số !", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("Vui lòng nhập đầy đủ thông tin!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("Khách hàng đã tồn tại!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } catch { } }
private void btnThem_Click(object sender, EventArgs e) { try { string maphong = cbbMaPhong.Text.Trim(); string matb = cbbMaTB.Text.Trim(); string tentb = txtTenTB.Text.Trim(); string sl = nudsl.Value.ToString(); string tt = cbbTTtb.Text.Trim(); if (maphong.Length != 0 && matb.Length != 0 && tentb.Length != 0 && tt.Length != 0) { bool check = database.Check(matb, "select MaTB from THIETBI_SD where MaPhong = N'" + maphong + "'"); if (check == true) { string update = "update THIETBI_SD set SoLuong = SoLuong + N'" + sl + "',TrangThai =N'" + tt + "' where MaPhong =N'" + maphong + "' and MaTB = N'" + matb + "'"; database.ThucThiKetNoi(update); MessageBox.Show("Hoàn Tất!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); database.loadDataGridView(dgvDichVu, "select sd.MaTB, tb.TenTB, sd.SoLuong from THIETBI_SD sd, THIETBI tb where sd.MaTB =tb.MaTB and sd.MaPhong = N'" + maphong + "'"); ResetSD(); } else { string insert = "INSERT INTO dbo.THIETBI_SD ( MaPhong, MaTB, SoLuong, TrangThai ) " + "VALUES(N'" + maphong + "', N'" + matb + "', '" + sl + "', N'" + tt + "')"; database.ThucThiKetNoi(insert); MessageBox.Show("Hoàn Tất!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); database.loadDataGridView(dgvDichVu, "select sd.MaTB, tb.TenTB, sd.SoLuong from THIETBI_SD sd, THIETBI tb where sd.MaTB =tb.MaTB and sd.MaPhong = N'" + maphong + "'"); ResetSD(); } } else { MessageBox.Show("Vui lòng nhập đủ thông tin Phòng và Thiết Bị!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } catch { MessageBox.Show("Đã xảy ra lỗi!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void btnThem_Click(object sender, EventArgs e) { try { string maphong = cbbMaPhong.Text; string tenphong = txtTenPhong.Text; string tt = cbbTrangThai.Text; string loaiphong = cbbLoaiPhong.Text; if (maphong.Length != 0 && tenphong.Length != 0 && tt.Length != 0 && loaiphong.Length != 0) { bool check = data.Check(maphong, "SELECT MaPhong from PHONG"); if (check == false) { string insert = "INSERT INTO PHONG(MaPhong,TenPhong,TrangThai) Values('" + maphong + "',N'" + tenphong + "',N'" + tt + "')"; data.ThucThiKetNoi(insert); string update = "update PHONG set PHONG.MaLoaiPhong = LOAIPHONG.MaLoaiPhong from LOAIPHONG where LOAIPHONG.TenLoaiPhong = N'" + loaiphong + "' and PHONG.MaPhong = N'" + maphong + "'"; data.ThucThiKetNoi(update); MessageBox.Show("Hoàn Tất!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Reset(); Loadd(); } else { MessageBox.Show("Phòng ban đã tồn tại, Không thể thêm!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("Bạn cần điền đầy đủ thông tin để hoàn tất!", "Mời bạn nhập lại!", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } catch { MessageBox.Show("Đã xảy ra lỗi", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void btnThuePhong_Click(object sender, EventArgs e) { try { string cmnd = comboBoxcmt.Text.Trim(); string makh = txtMaKH.Text.Trim(); string phong = cbbMaPhong.Text.Trim(); string Nthue = dtpNgayThue.Value.ToString(); string TienDC = txtDatCoc.Text.Trim(); string manv = lbmanv.Text.Trim(); if (cmnd.Length != 0 && phong.Length != 0 && TienDC.Length != 0) { bool check = database.Check(phong, "select MaPhong from PHONG where TrangThai = N'Trống'"); if (check == true) { if (Double.Parse(txtDatCoc.Text) >= 100000) { string insert = "insert into PHIEUTHUEPHONG values ( N'" + makh + "', N'" + manv + "', N'" + phong + "', N'" + Nthue + "', N'" + TienDC + "')"; database.ThucThiKetNoi(insert); string up = "update PHONG set TrangThai = N'Thuê' where MaPhong = '" + phong + "'"; database.ThucThiKetNoi(up); MessageBox.Show("Hoàn Tất!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); database.loadDataGridView(dgvThuePhong, "select * from PHIEUTHUEPHONG where MaPhong = N'" + phong + "'"); } else { MessageBox.Show("Đặt cọc tối thiếu 100.000!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("Phòng đã thuê!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("Vui lòng chọn số CMND của khách hàng và Phòng khách hàng muốn thuê!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } catch { MessageBox.Show("Vui lòng điền đủ thông tin!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void buttonDangKy_Click(object sender, EventArgs e) { string username = textBoxUsername.Text.TrimEnd(); string pass = textBoxPassword.Text.Trim(); string confirm = textBoxConfirm.Text.TrimEnd(); string email = textBoxEmail.Text.Trim(); bool check = database.Check(username, "SELECT Username FROM dbo.TaiKhoan"); if (username.Length != 0 && pass.Length != 0 && confirm.Length != 0 && email.Length != 0) { if (check == false) { if (confirm == pass) { string insert = "INSERT INTO dbo.TaiKhoan VALUES ( '" + username + "' ,'" + pass + "' ,N'" + email + "' ,1)"; database.ThucThiKetNoi(insert); DialogResult result; result = MessageBox.Show("Bạn muốn đăng nhập ngay không?", "Đăng Ký Thành Công", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { FormLOGIN lg = new FormLOGIN(); lg.Show(); this.Hide(); } } else { MessageBox.Show("Nhập lại mật khẩu không đúng!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { //labelThongBao.Text = "Tài khoản đã tồn tại! Vui lòng thử lại!"; MessageBox.Show("Username đã tồn tại!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("Vui lòng điền đầy đủ các trường!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void btnDangNhap_Click(object sender, EventArgs e) { if (txtTaiKhoan.Text.TrimEnd().Length != 0 && txtMatKhau.Text.TrimEnd().Length != 0) { string username = txtTaiKhoan.Text.TrimEnd(); string password = txtMatKhau.Text.TrimEnd(); bool check = database.Check(password, "Select MatKhau from TAIKHOAN where TenDangNhap = N'" + username + "'"); if (check == true) { useracc = username; FormHome m = new FormHome(); m.Show(); this.Hide(); //this.Close(); //th = new Thread(OpenFormHome); //th.SetApartmentState(ApartmentState.STA); //th.Start(); } else { MessageBox.Show("Username hoặc password không chính xác!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtTaiKhoan.Text = ""; txtMatKhau.Text = ""; checkBox1.Checked = false; this.ActiveControl = txtTaiKhoan; } } else { MessageBox.Show("Vui lòng nhập đầy đủ username và password!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtTaiKhoan.Text = ""; txtMatKhau.Text = ""; checkBox1.Checked = false; this.ActiveControl = txtTaiKhoan; } }