.net core酒店管理 例

2021-01-08 12:30

阅读:621

YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

标签:pdo   nta   summary   --   注册   end   omd   row   microsoft   

Api:

数据访问层:技术图片


public interface Iromdal
{
//显示房间信息表
List GetRooms();
//显示房间类别
List Roomtypes();
//详情反填
Room Fant(int uid);
//登录token
UserInfo LoginTok(UserInfo u);
//用户登录
int UserLogin(string Name, string Pwd);
//员工登录
int JobLogin(string Name, string Pwd);
//
List JobInfoShow();
//显示用户
List GetShow();
//删除用户
int UserDelete(int cid);
//反填用户信息
UserInfo UserFan(int aid);
//修改用户信息
int UserUpdate(UserInfo u);
//修改房间表
int RoomUpdate(Room r);
//管理员登录
int ManagerLogin(string Name, string Pwd);
//员工反填
JobInfo fanJob(int qid);
//删除房间
int RoomDelete(int rid);
//添加员工
int JobAdd(JobInfo j);
//删除员工
int jobDelete(int fid);
//修改员工信息
int JobUpdate(JobInfo j);
//cookie传值
UserInfo GetUser(int uid);
//显示订单
List getReser();
//注册(添加)用户8
int AddUser(UserInfo u);
//删除订单
int DeleteUser(int eid);
//结算
int FK(int Id, int RoomId, int WId);
//添加房间
int AddRoom(Room r);
//订单(3表)
List ShowRoom();
//显示留言
List showCaLiu();
//添加留言
int AddCaLiu(CaLiu c);
//删除留言
int DeleteCaLiu(int gid);
//财务
List GetMoney();

 

using Model;
using System;
using System.Collections.Generic;
using Dapper;
using System.Data.SqlClient;
using System.Linq;

namespace DAL
{
public class romdal : Iromdal
{
//详情
public Room Fant(int uid)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
var list = GetRooms();
var mod = list.Where(m => m.RoomId == uid).FirstOrDefault();
return mod;
}
}
//显示房间信息
public List GetRooms()
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query("select r.*,s.* from Room r join Roomtype s on r.ORStatId = s.ORStatId ").ToList();
}
}
//下拉框显示房间类型
public List Roomtypes()
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query("select * from Roomtype ").ToList();
}
}
//用户登录
public int UserLogin(string Name, string Pwd)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return Convert.ToInt32(conn.ExecuteScalar($"select * from UserInfo where Phone=‘{Name}‘ and pass=‘{Pwd}‘"));
}
}
//显示员工信息
public List JobInfoShow()
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query("select * from JobInfo ").ToList();
}
}
//显示用户
public List GetShow()
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query($"select * from UserInfo").ToList();
}
}
///


/// cookie传值
///

///
///
public UserInfo GetUser(int uid)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query($"select * from UserInfo where Id={uid}").FirstOrDefault();
}
}
//员工登录

public int JobLogin(string Name, string Pwd)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return Convert.ToInt32(conn.ExecuteScalar($"select * from JobInfo where Jtatu=‘{Name}‘ and JPass=‘{Pwd}‘"));
}
}
//修改房间表
public int RoomUpdate(Room r)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"update Room set RoId=‘{r.RoId}‘, ORStatId=‘{r.ORStatId}‘,RoShu=‘{r.RoShu}‘,Romney=‘{r.Romney}‘ where RoomId=‘{r.RoomId}‘");
}
}
//管理员登录
public int ManagerLogin(string Name, string Pwd)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return Convert.ToInt32(conn.ExecuteScalar($"select * from Manager where ManagerName=‘{Name}‘ and ManagerPass=‘{Pwd}‘"));
}
}
//员工反填
public JobInfo fanJob(int qid)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
var list = JobInfoShow();
var mod = list.Where(m => m.JId == qid).FirstOrDefault();
return mod;
}
}
//删除房间
public int RoomDelete(int rid)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"delete from Room where RoomId=‘{rid}‘");
}
}
//员工添加
public int JobAdd(JobInfo j)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"insert into JobInfo values(‘{j.JName}‘,‘{j.JSex}‘,‘{j.Jtatu}‘,‘{j.JPass}‘,‘{j.JJob}‘,‘{j.JMoeny}‘)");
}
}
//删除员工
public int jobDelete(int fid)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"delete from JobInfo where JId=‘{fid}‘");
}
}
//修改员工信息
public int JobUpdate(JobInfo j)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"update JobInfo set JName=‘{j.JName}‘,JSex=‘{j.JSex}‘,Jtatu=‘{j.Jtatu}‘,JPass=‘{j.JPass}‘,JJob=‘{j.JJob}‘,JMoeny=‘{j.JMoeny}‘ where JId={j.JId}");
}
}
//删除用户
public int UserDelete(int cid)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"delete from UserInfo where Id=‘{cid}‘");
}
}
//反填用户信息
public UserInfo UserFan(int aid)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
var list = GetShow();
var mod = list.Where(m => m.Id == aid).FirstOrDefault();
return mod;
}
}
//修改用户信息
public int UserUpdate(UserInfo u)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"update UserInfo set UserId=‘{u.UserId}‘,UName=‘{u.UName}‘,Sex=‘{u.Sex}‘,statu=‘{u.statu}‘,HeiId=‘{u.HeiId}‘,BTime=‘{u.BTime}‘,OTime=‘{u.OTime}‘,pass=‘{u.pass}‘,Email=‘{u.Email}‘,sites=‘{u.sites}‘,Phone=‘{u.Phone}‘,SMoney=‘{u.SMoney}‘ where Id=‘{u.Id}‘ ");
}
}
//显示订单
public List getReser()
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query($"select r.*,u.UName from RoomReservation r join UserInfo u on r.ORUserId = u.Id").ToList();
}
}
//注册(添加)用户
public int AddUser(UserInfo u)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"insert into UserInfo values(‘{u.UserId}‘,‘{u.UName}‘,‘{u.Sex}‘,‘{u.statu}‘,‘{u.HeiId}‘,‘{u.BTime}‘,‘{u.OTime}‘,‘{u.pass}‘,‘{u.Email}‘,‘{u.Phone}‘,‘{u.SMoney}‘) ");
}
}
//删除订单
public int DeleteUser(int eid)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"delete from RoomReservation where ORId=‘{eid}‘");
}
}
//房间添加
public int AddRoom(Room r)
{
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"insert into Room values(‘{r.RoId}‘,‘{r.ORStatId}‘,‘{r.RoShu}‘,‘{r.Romney}‘)");
}
}
////结算
//public int JIeShuan(int id, int ORId)
//{
// using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
// {
// object b=conn.Execute("")
// }
//}
}
///


/// 还款
///

/// 客户Id
/// 房间Id
///
public int FK(int Id, int RoomId, int WId)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
object ud = conn.ExecuteScalar($"select SMoney from UserInfo where Id={Id}");
object rd = conn.ExecuteScalar($"select Romney from Room where RoomId={RoomId}");
object sl = conn.ExecuteScalar($"select RoShu from Room where RoomId={RoomId}");
if (Convert.ToInt32(ud) >= Convert.ToInt32(rd))
{

int n = conn.Execute($"update UserInfo set SMoney=SMoney-{rd} where Id={Id} ");
if (n > 0)
{
if (Convert.ToInt32(sl) > 0)
{
int m = conn.Execute($"update Room set RoShu=RoShu-{1} where RoomId={RoomId} ");
if (m > 0)
{
conn.Execute($"update CwMoeny set Wmoney=Wmoney+{rd} where WId={WId} ");
}

return m;
}
else
{
return -1;
}

}
return n;
}
else
{
return -1;
}
}
}
//订单(3表)
public List ShowRoom()
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query($"select u.Id,r.RoomId,r.RoId,r.RoId,r.RoShu,r.Romney,c.WId,u.UName,u.BTime,u.OTime from UserInfo u join Room r on u.Id = r.RoomId join CwMoeny c on c.WId = r.RoomId").ToList();
}
}
//留言显示
public List showCaLiu()
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query($"select * from CaLiu").ToList();
}
}
//添加留言
public int AddCaLiu(CaLiu c)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"insert into CaLiu values(‘{c.Lleave}‘);");
}
}
//删除留言
public int DeleteCaLiu(int gid)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Execute($"delete from CaLiu where LId=‘{gid}‘");
}
}
//登录token
public UserInfo LoginTok(UserInfo u)
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query($"select * from UserInfo where Phone=‘{u.Phone}‘ and pass=‘{u.pass}‘").FirstOrDefault();
}
}
//财务
public List GetMoney()
{
using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=hotel;Integrated Security=True"))
{
return conn.Query($"select * from CwMoeny").ToList();
}
}
}
}

 

controller:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Threading.Tasks;
using DAL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;
using WebApplication1.Models;

namespace WebApplication1.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ValuesController : ControllerBase
{
private Iromdal _bll;
public ValuesController(Iromdal Iromdal)
{
_bll = Iromdal;
}
[HttpGet]
//显示房间信息
public async Task GetRooms(int pageIndex = 1, int pageSize = 3)
{
List rooms = await Task.Run(() => { return _bll.GetRooms(); });
pageRoom fanrom = new pageRoom();
fanrom.TotalCount = rooms.Count / pageSize + (rooms.Count % pageSize > 0 ? 1 : 0);
fanrom.Rooms = rooms.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
return fanrom;
}
[HttpGet]
//下拉框房间类型
public List Roomtypes()
{
return _bll.Roomtypes();
}
//显示房间类型
[HttpGet]

//详情
public Room Fant(int uid)
{
return _bll.Fant(uid);
}
//用户登录
[HttpGet]
public int UserLogin(string Name, string Pwd)
{
return _bll.UserLogin(Name, Pwd);
}
//员工登录
[HttpGet]
public int JobLogin(string Name, string Pwd)
{
return _bll.JobLogin(Name, Pwd);
}
[HttpGet]
//显示员工信息
public async Task JobInfoShow(int pageIndex = 1, int pagSize = 3)
{
List list = await Task.Run(() => { return _bll.JobInfoShow(); });
PageTouZi touZi = new PageTouZi();
touZi.TotalCount = list.Count / pagSize + (list.Count % pagSize > 0 ? 1 : 0);
touZi.List = list.Skip((pageIndex - 1) * pagSize).Take(pagSize).ToList();
return touZi;
}
[HttpGet]
//显示用户
public List GetShow()
{
return _bll.GetShow();
}

[HttpPost]
//删除用户
public int UserDelete(int cid)
{
return _bll.UserDelete(cid);
}
[HttpGet]
//反填用户信息
public UserInfo UserFan(int aid)
{
return _bll.UserFan(aid);
}
[HttpPost]
//修改房间表
public int RoomUpdate([FromForm] Room r)
{
return _bll.RoomUpdate(r);
}
[HttpGet]
//管理员登录
public int ManagerLogin(string Name, string Pwd)
{
return _bll.ManagerLogin(Name, Pwd);
}
//员工反填
[HttpGet]
public JobInfo fanJob(int qid)
{
return _bll.fanJob(qid);
}
//删除房间
[HttpPost]
public int RoomDelete(int rid)
{
return _bll.RoomDelete(rid);
}
//员工添加
[HttpPost]
public int JobAdd([FromForm] JobInfo j)
{
return _bll.JobAdd(j);
}
//删除员工
[HttpPost]
public int jobDelete(int fid)
{
return _bll.jobDelete(fid);
}
[HttpPost]
//修改员工信息
public int JobUpdate([FromForm] JobInfo j)
{
return _bll.JobUpdate(j);
}
//cookie传值
[HttpGet]
public UserInfo GetUser(int uid)
{
return _bll.GetUser(uid);
}
[HttpGet]
//显示订单
public List getReser()
{
return _bll.getReser();
}
[HttpPost]
//注册(添加)用户
public int AddUser(UserInfo u)
{
return _bll.AddUser(u);
}
//退订单
[HttpPost]
public int DeleteUser(int eid)
{
return _bll.DeleteUser(eid);
}
[HttpPost]
//房间添加
public int AddRoom([FromForm]Room r)
{
return _bll.AddRoom(r);
}
[HttpPost]
//修改用户信息
public int UserUpdate([FromForm]UserInfo u)
{
return _bll.UserUpdate(u);
}
[HttpPost]
///


/// 还款
///

/// 客户Id
/// 房间Id
///
public int FK(int Id, int RoomId, int WId)
{
return _bll.FK(Id, RoomId, WId);
}
[HttpGet]
//显示房间xin
public List ShowRoom()
{
return _bll.ShowRoom();
}
//留言显示
[HttpGet]
public List showCaLiu()
{
return _bll.showCaLiu();
}
//添加留言
[HttpPost]
public int AddCaLiu([FromForm]CaLiu c)
{
return _bll.AddCaLiu(c);
}
//删除留言
[HttpPost]
public int DeleteCaLiu(int gid)
{
return _bll.DeleteCaLiu(gid);
}
//登录Token
public string LoginTok(UserInfo u)
{
UserInfo user = _bll.LoginTok(u);
if (user!=null)
{
JWTHelper jwt = new JWTHelper();
Dictionary dic = new Dictionary();
dic.Add("Phone", user.Phone);
dic.Add("Id", user.Id);
dic.Add("pass", user.pass);
string token = jwt.GetToken(dic, 3000);
return token;
}
else
{
return null;
}
}
//发送邮箱
[HttpPost]
public int SendMailMethod([FromForm]EmailModel model)
{
try
{
string[] arr = null;
if (model.RecMails.Contains(","))
{
arr = model.RecMails.Split(‘,‘);
}
else
{
arr = new string[] { model.RecMails };
}

SendMail mail = new SendMail(arr, "31900477@qq.com", model.BodyContent, model.Title, "sfeamvgjafykbgdh");
mail.Send();
return 1;
}
catch (Exception)
{
return 0;
}
}
//财务
[HttpGet]
public List GetMoney()
{
return _bll.GetMoney();
}
}
}

MVC:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication1.Controllers
{
public class jobController2 : Controller
{
//员工登录
public IActionResult LoginJob()
{
return View();
}
//员工显示
public IActionResult ShowJob()
{
return View();
}
//所有房间信息
public IActionResult RoomShowN()
{
return View();
}
//详情修改房间信息
public IActionResult RoomUp(int RoomId)
{
ViewBag.Sid = RoomId;
return View();
}
//预订单
public IActionResult YVDing()
{
return View();
}
//注册
public IActionResult AddJobInfo()
{
return View();
}
//留言板
public IActionResult LIYYan()
{
return View();
}
//邮箱
public IActionResult YXian()
{
return View();
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication1.Controllers
{
public class ManaController : Controller
{
//管理员登录
public IActionResult HuanLogin()
{
return View();
}
//显示员工页面
public IActionResult HuanShow()
{
return View();
}
//显示员工页面
public IActionResult FangShow()
{
return View();
}
//修改员工信息
public IActionResult XiuJob(int JId)
{
ViewBag.Cid = JId;
return View();
}
//添加改员工信息
public IActionResult AddJob()
{
return View();
}
//修改房间
public IActionResult XiuRoom(int RoomId)
{
ViewBag.Sid = RoomId;
return View();
}
//添加房间
public IActionResult AddRoom()
{
return View();
}
//显示客户页面
public IActionResult UserShow()
{
return View();
}
//修改客户信息
public IActionResult XiuUser(int id)
{
ViewBag.cid = id;
return View();
}
//订单信息表
public IActionResult DingDan()
{
return View();
}
//财务表
public IActionResult CMoney()
{
return View();
}
}
}

 

view://显示发送邮箱


@{
ViewData["Title"] = "ShowJob";
}




  • 首页

  • 所有房间信息

  • 订单信息

  • 留言板


  • 更多服务


    发送邮件

    服务2

    服务3



  • 社区





carousel模块快速使用



  • 用户信息




  • 安全管理

    退出



//…
});
function sd() {
if (confirm("确认退出吗?")) {
location.href = ‘/jobController2/LoginJob.cshtml‘;
}
else {
return;
}
}
































客户编号 姓名 客户性别 身份证号 客户类型 入住时间 结束时间 邮箱 联系地址 联系电话























 

.net core酒店管理 例

标签:pdo   nta   summary   --   注册   end   omd   row   microsoft   

原文地址:https://www.cnblogs.com/lgc200421/p/13544346.html


评论


亲,登录后才可以留言!