protected void Page_Load(object sender, EventArgs e) { DataModel dm = new DataModel(); lo = new LabOrder(); if (Request.Params["week"] == null || Request.Params["week"] == "") { dm.ReturnJsonMsg(Response, 0, "未知周次!"); } if (Request.Params["cls"] == null || Request.Params["cls"] == "") { dm.ReturnJsonMsg(Response, 0, "未知节次!"); } if (Request.Params["wd"] == null || Request.Params["wd"] == "") { dm.ReturnJsonMsg(Response, 0, "未知工作日!"); } if (Request.Params["lab"] == null || Request.Params["lab"] == "") { dm.ReturnJsonMsg(Response, 0, "未知实验室!"); } lo.OrderCls = Convert.ToInt32(Request.Params["cls"]); lo.OrderWeek = Convert.ToInt32(Request.Params["week"]); lo.OrderWeekday = Convert.ToInt32(Request.Params["wd"]); //用户信息 luser = dm.GetUser(Convert.ToInt32(Session["lxyLabUserID"])); //实验室信息 lab = dm.GetLab(Convert.ToInt32(Request.Params["lab"])); }
public void ProcessRequest(HttpContext context) { DataModel dm = new DataModel(); LabOrder lo = new LabOrder(); if (context.Request.Params["OrderLab"] == null || context.Request.Params["OrderLab"] == "") { dm.ReturnJsonMsg(context.Response, 0, "未知实验室!"); } if (context.Request.Params["OrderWeek"] == null || context.Request.Params["OrderWeek"] == "") { dm.ReturnJsonMsg(context.Response, 0, "未知 周次!"); } if (context.Request.Params["OrderWeekday"] == null || context.Request.Params["OrderWeekday"] == "") { dm.ReturnJsonMsg(context.Response, 0, "未知 工作日!"); } if (context.Request.Params["OrderCls"] == null || context.Request.Params["OrderCls"] == "") { dm.ReturnJsonMsg(context.Response, 0, "未知 节次!"); } if (context.Request.Params["OrderTitle"] == null || context.Request.Params["OrderTitle"] == "") { dm.ReturnJsonMsg(context.Response, 0, "未填写预约实验课题!"); } if (context.Request.Params["OrderAmount"] == null || context.Request.Params["OrderAmount"] == "") { dm.ReturnJsonMsg(context.Response, 0, "未填写预约人数!"); } //用户 lo.OrderUser = Convert.ToInt32(context.Session["lxyLabUserID"]); //实验室 lo.OrderLab = Convert.ToInt32(context.Request.Params["OrderLab"]); lo.OrderAmount = Convert.ToInt32(context.Request.Params["OrderAmount"]); lo.OrderCls = Convert.ToInt32(context.Request.Params["OrderCls"]); lo.OrderIntro = context.Request.Params["OrderIntro"]; lo.OrderTerm = dm.GetCurrntTerm().TermID; lo.OrderTitle = context.Request.Params["OrderTitle"]; lo.OrderPostTime = DateTime.Now; lo.OrderWeek = Convert.ToInt32(context.Request.Params["OrderWeek"]); lo.OrderWeekday = Convert.ToInt32(context.Request.Params["OrderWeekday"]); dm.SaveLabOrder(lo); dm.ReturnJsonMsg(context.Response,1,"预约成功!",lo.OrderID); }
protected void Page_Load(object sender, EventArgs e) { if (Request.Params["id"] == null || Request.Params["id"].Trim() == "") { hasOrder = false; } else { DataModel dm=new DataModel(); int id = Convert.ToInt32(Request.Params["id"].Trim()); lo = dm.GetLabOrder(id); if (lo != null) { luser = dm.GetUser(lo.OrderUser); inos = dm.GetLabOrderInst(lo.OrderID); } else { hasOrder = false; } } }
public int SaveLabOrder(LabOrder lo) { InitCommand(); if (lo.OrderID == 0) { //Insert new user cmd.CommandText = "INSERT INTO Order_tb (OrderUser,OrderLab,OrderAmount,OrderTitle,OrderTerm,OrderWeek,OrderWeekday,OrderCls,OrderIntro,OrderPostTime)" +" VALUES (@OrderUser,@OrderLab,@OrderAmount,@OrderTitle,@OrderTerm,@OrderWeek,@OrderWeekday,@OrderCls,@OrderIntro,@OrderPostTime)"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@OrderUser", lo.OrderUser); cmd.Parameters.AddWithValue("@OrderLab",lo.OrderLab); cmd.Parameters.AddWithValue("@OrderAmount", lo.OrderAmount); cmd.Parameters.AddWithValue("@OrderTitle", lo.OrderTitle); cmd.Parameters.AddWithValue("@OrderTerm",lo.OrderTerm); cmd.Parameters.AddWithValue("@OrderWeek", lo.OrderWeek); cmd.Parameters.AddWithValue("@OrderWeekday", lo.OrderWeekday); cmd.Parameters.AddWithValue("@OrderCls", lo.OrderCls); cmd.Parameters.AddWithValue("@OrderIntro", lo.OrderIntro); OleDbParameter parameter = new OleDbParameter(); parameter.OleDbType = OleDbType.DBDate; parameter.Value = lo.OrderPostTime; cmd.Parameters.Add(parameter); cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT @@Identity "; lo.OrderID = (int)cmd.ExecuteScalar(); } else { cmd = new OleDbCommand(); cmd.Connection = conn; cmd.CommandText = "UPDATE Order_tb SET " + " OrderUser=@OrderUser,OrderLab=@OrderLab,OrderAmount=@OrderAmount,OrderTitle=@OrderTitle,OrderTerm=@OrderTerm," + " OrderWeek=@OrderWeek,OrderWeekday=@OrderWeekday ,OrderCls=@OrderCls,OrderIntro=@OrderIntro where UserID=@userID"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@OrderUser", lo.OrderUser); cmd.Parameters.AddWithValue("@OrderLab", lo.OrderLab); cmd.Parameters.AddWithValue("@OrderAmount", lo.OrderAmount); cmd.Parameters.AddWithValue("@OrderTitle", lo.OrderTitle); cmd.Parameters.AddWithValue("@OrderTerm", lo.OrderTerm); cmd.Parameters.AddWithValue("@OrderWeek", lo.OrderWeek); cmd.Parameters.AddWithValue("@OrderWeekday", lo.OrderWeekday); cmd.Parameters.AddWithValue("@OrderCls", lo.OrderCls); cmd.Parameters.AddWithValue("@OrderIntro", lo.OrderIntro); cmd.ExecuteNonQuery(); } conn.Close(); return lo.OrderID; }
public LabOrder GetLabOrder(int id) { string sqlStr = "select * from ((Order_tb left join User_tb on Order_tb.OrderUser = User_tb.UserID)left join Lab_tb on Order_tb.OrderLab = Lab_tb.LabID) where OrderID = @id"; InitCommand(); cmd.CommandText = sqlStr; cmd.Parameters.AddWithValue("@id",id); dr = cmd.ExecuteReader(); LabOrder lo = new LabOrder(); if (dr.Read()) { lo.OrderID = Convert.ToInt32(dr["OrderID"]); lo.OrderAmount = Convert.ToInt32(dr["OrderAmount"]); lo.OrderCls = Convert.ToInt32(dr["OrderCls"]); lo.OrderIntro = dr["OrderIntro"].ToString(); lo.OrderLab = Convert.ToInt32(dr["OrderLab"]); lo.OrderLabName = dr["LabName"].ToString(); lo.OrderReplay = dr["OrderReplay"].ToString(); lo.OrderStatus = Convert.ToInt32(dr["OrderStatus"]); lo.OrderTerm = Convert.ToInt32(dr["OrderTerm"]); lo.OrderTitle = dr["OrderTitle"].ToString(); lo.OrderUser = Convert.ToInt32(dr["OrderUser"]); lo.OrderUserIdentity = Convert.ToInt32(dr["UserIdentity"]); lo.OrderUserName = dr["UserName"].ToString(); lo.OrderWeek = Convert.ToInt32(dr["OrderWeek"]); lo.OrderWeekday = Convert.ToInt32(dr["OrderWeekday"]); } dr.Close(); conn.Close(); return lo; }
/// <summary> /// 获取实验室预约信息 /// </summary> /// <param name="page">页数</param> /// <param name="pageSize">每页数</param> /// <param name="sort">排序元</param> /// <param name="sortOrder">desc或asc</param> /// <param name="lab">查询实验室</param> /// <param name="term">查询学期</param> /// <param name="userNum">查询用户</param> /// <param name="week">查询周</param> /// <param name="weekday">查询</param> /// <param name="cls">查询节次</param> /// <returns>带有total(总记录条数)和各个记录的信息</returns> public LabOrdersWithTotal GetBookLabs(int page,int pageSize, string sort,string sortOrder, int lab,int term,string userNum,int week,int weekday,int cls) { string lab_s = lab == 0 ? " " : " and OrderLab = " + lab.ToString() + " "; string term_s = term == 0 ? " " :" and OrderTerm= "+ term.ToString(); string week_s = week==0? " ":" and OrderWeek = "+ week.ToString(); string weekday_s = weekday==0?" ":" and OrderWeekday= "+ weekday.ToString(); string cls_s = cls == 0 ? " " : " and OrderCls = " + cls.ToString(); string user_s = userNum == "" ? " " :" and OrderUser = "******""; string where_s = " where 1=1 " + user_s + lab_s + term_s + week_s + weekday_s + cls_s + " "; string order_s = " order by "+sort+ " "+ sortOrder+" "; string from_s=" from ((Order_tb left join User_tb on Order_tb.OrderUser = User_tb.UserID)left join Lab_tb on Order_tb.OrderLab = Lab_tb.LabID) "; string cmdText; if (page>0) { //分页 if (page == 1) { //取第一页 cmdText = "select top " + pageSize + " * " +from_s + where_s + order_s; } else { //取大于第一页的数据 cmdText = "select top " + pageSize + " * " + from_s + where_s + " and OrderID not in ( select top " + pageSize * (page - 1) + " OrderID from Order_tb " + where_s + order_s +" ) " + order_s; } } else { cmdText = "select * " + from_s + where_s + order_s; } LabOrdersWithTotal lbot = new LabOrdersWithTotal(); InitCommand(); cmd.CommandText = cmdText; dr = cmd.ExecuteReader(); while (dr.Read()) { LabOrder lo = new LabOrder(); lo.OrderID =Convert.ToInt32( dr["OrderID"]); lo.OrderAmount = Convert.ToInt32(dr["OrderAmount"]); lo.OrderCls = Convert.ToInt32(dr["OrderCls"]); lo.OrderIntro = dr["OrderIntro"].ToString(); lo.OrderLab =Convert.ToInt32( dr["OrderLab"]); lo.OrderLabName = dr["LabName"].ToString(); lo.OrderReplay = dr["OrderReplay"].ToString(); lo.OrderStatus = Convert.ToInt32(dr["OrderStatus"]); lo.OrderTerm = Convert.ToInt32(dr["OrderTerm"]); lo.OrderTitle = dr["OrderTitle"].ToString(); lo.OrderUser = Convert.ToInt32(dr["OrderUser"]); if (lo.OrderUser != 0) { lo.OrderUserIdentity = Convert.ToInt32(dr["UserIdentity"]); lo.OrderUserName = dr["UserName"].ToString(); } lo.OrderWeek = Convert.ToInt32(dr["OrderWeek"]); lo.OrderWeekday = Convert.ToInt32(dr["OrderWeekday"]); lbot.rows.Add(lo); } dr.Close(); cmd.CommandText = "select count(OrderID) from Order_tb " +where_s; lbot.total = Convert.ToInt32(cmd.ExecuteScalar()); conn.Close(); return lbot; }