public void CapNhatLoaiKhachHang() { SqlCommand cmd = new SqlCommand("sp_capnhatloaikhachhang"); cmd.CommandType = CommandType.StoredProcedure; try { db.ThucThiLenh(cmd); } catch (Exception e) { XtraMessageBox.Show("Lỗi " + e.Message); } }
public void ThemDonViTinh(string TenDonVi) { using (SqlCommand cmd = new SqlCommand("SP_THEMDVITINH")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@TENDVI", SqlDbType.NVarChar).Value = TenDonVi; try { db.ThucThiLenh(cmd); MessageBox.Show("Thêm dữ liệu thành công!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Lỗi!" + ex.Message, "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public void ThemNhanVien(string tennhanvien, string dienthoai, string macv) { SqlCommand cmd = new SqlCommand("sp_ThemNhanVien"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@HOTENNV", SqlDbType.NVarChar).Value = tennhanvien; cmd.Parameters.Add("@DIENTHOAINV", SqlDbType.Char).Value = dienthoai; cmd.Parameters.Add("@MACV", SqlDbType.Char).Value = macv; try { db.ThucThiLenh(cmd); XtraMessageBox.Show("Thêm thành công!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { XtraMessageBox.Show("Lỗi!" + ex.Message, "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ThemLoaiSanPham(string maloai, string TenLoai) { using (SqlCommand cmd = new SqlCommand("SP_THEMLOAISANPHAM")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@maloai", SqlDbType.Char).Value = maloai; cmd.Parameters.Add("@TENLOAI", SqlDbType.NVarChar).Value = TenLoai; try { db.ThucThiLenh(cmd); //MessageBox.Show("Thêm dữ liệu thành công!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Lỗi!" + ex.Message, "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public void SuaDonDatHang(string maddh, string masp, int soluongdat) { using (SqlCommand cmd = new SqlCommand("SP_SUADONDATHANG")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MADDH", SqlDbType.Char).Value = maddh; cmd.Parameters.Add("@MASP", SqlDbType.Char).Value = masp; cmd.Parameters.Add("@SLDAT", SqlDbType.Int).Value = soluongdat; try { db.ThucThiLenh(cmd); XtraMessageBox.Show("Cập nhật dữ liệu thành công", "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Lỗi!" + ex.Message, "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnSaoLuu_Click(object sender, EventArgs e) { try { SqlCommand cmd = new SqlCommand(@"BACKUP DATABASE " + System.IO.Path.GetFileNameWithoutExtension((saveFileDialog.FileName.Substring(saveFileDialog.FileName.LastIndexOf("\\") + 1))) + " TO DISK='" + txtSaoLuu.Text + "'"); db.ThucThiLenh(cmd); MessageBox.Show("Sao lưu dữ liệu thành công!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Lỗi\t " + ex.Message); } }
private void btnPhucHoi_Click(object sender, EventArgs e) { try { SqlCommand cmd = new SqlCommand(@"use master RESTORE DATABASE " + Path.GetFileNameWithoutExtension(OpenFile.FileName.Substring(OpenFile.FileName.LastIndexOf("\\") + 1)) + " FROM DISK='" + txtSaoLuu.Text + "' with replace"); db.ThucThiLenh(cmd); MessageBox.Show("Phục hồi dữ liệu thành công!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Lỗi\t " + ex.Message); } }
public void ThemNguoiDung(string TenDangNhap, string MatKhau, int QuyenAdmin, int QuyenThem, int QuyenXoa, int QuyenSua) { try { using (SqlCommand cmd = new SqlCommand("SP_THEMNGUOIDUNG ") { CommandType = CommandType.StoredProcedure }) { cmd.Parameters.Add("@TENDN", SqlDbType.VarChar).Value = TenDangNhap; cmd.Parameters.Add("@MATKHAU", SqlDbType.VarChar).Value = MatKhau; cmd.Parameters.Add("@ADMIN", SqlDbType.Bit).Value = QuyenAdmin; cmd.Parameters.Add("@THEM", SqlDbType.Bit).Value = QuyenThem; cmd.Parameters.Add("@XOA", SqlDbType.Bit).Value = QuyenXoa; cmd.Parameters.Add("@SUA", SqlDbType.Bit).Value = QuyenSua; db.ThucThiLenh(cmd); MessageBox.Show("Thêm thành công", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("Thêm dữ liệu không thành công", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void DOIMATKHAU(string tendangnhap, string matkhaucu, string matkhaumoi) { using (SqlCommand cmd = new SqlCommand("SP_DOIMATKHAU")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@TENDANGNHAP", SqlDbType.NVarChar).Value = tendangnhap; cmd.Parameters.Add("@MATKHAUCU", SqlDbType.VarChar).Value = matkhaucu; cmd.Parameters.Add("@MATKHAUMOI", SqlDbType.VarChar).Value = matkhaumoi; try { db.ThucThiLenh(cmd); MessageBox.Show("Đổi mật khẩu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Lỗi!" + ex.Message, "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }