protected void jieyue_Click(object sender, EventArgs e) { if (Session["user"] != null) { if (Session["type"].ToString() == null) { string username = Session["user"].ToString(); string bookname = Session["name"].ToString(); Bookinfo user = new Bookinfo(username); user = bbl.selectuser(user); Bookinfo book = new Bookinfo(bookname); book = bbl.selectebook(book); Bookinfo lg = new Bookinfo(username, bookname, user.userid, book.bookid); OperationResult op = bbl.Regist(lg); if (op.ToString() == "exist") { Response.Write("记录已存在"); } else if (op.ToString() == "success") { Response.Write("成功"); } } else { } } }
private void Button1_Click(object sender, EventArgs e) { using (busticketContext context = new busticketContext()) { Bookinfo bookinfo = new Bookinfo(); bookinfo.Bid = textBox1.Text; bookinfo.Start = textBox2.Text; bookinfo.End = textBox3.Text; bookinfo.StartTime = textBox4.Text; bookinfo.EndTime = textBox5.Text; bookinfo.BusCode = textBox6.Text; bookinfo.Count = int.Parse(textBox7.Text); bookinfo.Price = textBox8.Text; Bookinfo temp = context.Bookinfo.FirstOrDefault(x => x.Bid == bookinfo.Bid); if (temp != null) { MessageBox.Show("线路已存在!", "提示"); } else { context.Add(bookinfo); MessageBox.Show("添加成功!", "提示"); context.SaveChanges(); } } }
/// <summary> /// 借书 条形码提交后台获取书名 /// </summary> /// <param name="coll">参数cool</param> /// <returns>书名</returns> public string GetBookName(FormCollection coll) { string result = string.Empty; try { if (coll.Count != 0) { string orderNumguid = coll["bookid"] != null ? coll["bookid"].Trim() : string.Empty; Guid orderguid = new Guid(); if (Guid.TryParse(orderNumguid, out orderguid)) { GetBookItemInfoMgr getBookItemInfoMgr = new GetBookItemInfoMgr(); Guid bookid = getBookItemInfoMgr.GetBookID(orderguid); Bookinfo bookinfo = new Bookinfo(); GetBookInfoMgr getBookInfoMgr = new GetBookInfoMgr(); bookinfo = getBookInfoMgr.GetBookInfoBybookid(bookid); ViewBag.Bookname = bookinfo.Title; result = bookinfo.Title; } } } catch { result = string.Empty; } finally { LogManager.Log.WriteUiAcc("shaoyu", "UserInfo", "shaoyu", "127.0.0.1", string.Empty, string.Empty, "查询显示用户信息", null); } return(result); }
/// <summary> /// 检测借书人信息 /// </summary> /// <param name="username">借书人</param> /// <returns>提示信息</returns> public string Checkuser(string username) { string message = string.Empty; UerInfo userinfo = new UerInfo(); GetLoanInfoMgr getLoanInfoMgr = new GetLoanInfoMgr(); userinfo = getLoanInfoMgr.CheckUserInfo(username); if (userinfo.Booknum >= 5) { userinfo.Isborrow = false; message = "每人最多可以借阅5本书,你已经借阅5本书,不能再借阅。#0"; } else if (userinfo.OutBack > 0) { GetBookInfoMgr getBookInfoMgr = new GetBookInfoMgr(); GetBookItemInfoMgr getBookItemInfoMgr = new GetBookItemInfoMgr(); StringBuilder messagesb = new StringBuilder("您所借图书:"); foreach (Guid orderid in userinfo) { Guid bookid = getBookItemInfoMgr.GetBookID(orderid); Bookinfo borrowbookinfo = getBookInfoMgr.GetBookInfoBybookid(bookid); messagesb.Append("《" + borrowbookinfo.Title + "》"); } messagesb.Append(" 超期依然未归还,请归还再借阅。#0"); message = messagesb.ToString(); userinfo.Isborrow = false; } else { message = this.GetreturnMessage(username); } return(message); }
private void Button1_Click(object sender, EventArgs e)//CanelTicket() { DialogResult result = MessageBox.Show("确定取消本订单?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { for (int i = listView1.SelectedItems.Count - 1; i >= 0; i--) { ListViewItem item = listView1.SelectedItems[i]; using (busContext context = new busContext()) { Ticket ticket = context.Ticket.FirstOrDefault(x => x.Tid == item.Text); Bookinfo bookinfo = context.Bookinfo.FirstOrDefault(x => x.Bid == ticket.Bid); DateTime dt; DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "yyyy/MM/dd hh:mm"; dt = Convert.ToDateTime(ticket.StartTime, dtFormat); var now = DateTime.Now; if (DateTime.Compare(dt, now) > 0) { bookinfo.Surplus++; context.Remove(ticket); context.SaveChanges(); MessageBox.Show("取消订单成功 !", "提示"); listView1.Items.Remove(item); } else { MessageBox.Show("订单已经过期,无法取消 !", "提示"); } } } } }
public int Adde(Bookinfo user) { string cmdText = "insert into T_EbookShelf(userName,bookName,bookID,bookName) values(@userName,@bookName,@bookID,@bookName)"; string[] paramList = { "@userName", "@bookName", "@bookID", "@bookName" }; object[] valueList = { user.username, user.bookname }; return(db.ExecuteNoneQuery(cmdText, paramList, valueList)); }
/// <summary> /// 上传电子书的 /// </summary> /// <param name="user"></param> /// <returns></returns> public OperationResult Registe(Bookinfo file) { int mun = dao.Adde(file); if (mun == 1) { return(OperationResult.success); } return(OperationResult.failure); }
/// <summary> /// 根据name查修 /// </summary> /// <returns></returns> public Bookinfo selectuser(Bookinfo user) { Bookinfo tep = dao.Queryuser(user.username); if (tep != null) { return(tep); } else { return(null); } }
/// <summary> /// 获取全部图书信息 /// </summary> /// <param name="conn">数据库连接</param> /// <returns>图书信息</returns> public List <Bookinfo> GetAllBookInfo(IDbConnection conn) { // 图书信息查询语句 string sqlforbookinfo = "select Top(100) BookID, Title, Decrible from BookInfo"; List <Bookinfo> bookinfoList = new List <Bookinfo>(); try { using (SqlDataReader result = SqlHelper.ExecuteReader(null, conn as SqlConnection, sqlforbookinfo, null)) { if (result.HasRows) { while (result.Read()) { Bookinfo bookinfo = new Bookinfo(); // 图书名 if (!result.IsDBNull(0)) { bookinfo.BookID = result.GetGuid(0); } // 图书名 if (!result.IsDBNull(1)) { bookinfo.Title = result.GetString(1); } // 图书描述 if (!result.IsDBNull(2)) { bookinfo.Decrible = result.GetString(2); } bookinfoList.Add(bookinfo); } } result.Close(); } } catch (Exception exp) { AppException appexp = new AppException("获取全部图书信息", exp, ExceptionLevel.Error); LogManager.Log.WriteException(appexp); } return(bookinfoList); }
public int Price(Bookinfo bookinfo, Line line) { int x = 0, y = 0, price = 0; if (textBox1.Text == line.Start) { x = 1; } if (textBox1.Text == line.Mid0) { x = 2; } if (textBox1.Text == line.Mid1) { x = 3; } if (textBox1.Text == line.Mid2) { x = 4; } if (textBox2.Text == line.Mid0) { y = 2; } if (textBox2.Text == line.Mid1) { y = 3; } if (textBox2.Text == line.Mid2) { y = 4; } if (textBox2.Text == line.End) { y = 5; } int[] p = { 0, 0, 0, 0 }; p[0] = int.Parse(bookinfo.Price0); p[1] = int.Parse(bookinfo.Price1); p[2] = int.Parse(bookinfo.Price2); p[3] = int.Parse(bookinfo.Price3); while (x < y) { price += p[x - 1]; x++; } return(price); }
public Bookinfo Queryuser(string name) { string cmdText = "select * from T_UserInfo where userName = @userName"; string[] paramList = { "@userName" }; object[] valueList = { name }; SqlDataReader reader = db.ExecuteReader(cmdText, paramList, valueList); Bookinfo book = new Bookinfo(); if (reader.Read()) { book.userid = reader["userName"].ToString(); } reader.Close(); return(book); }
public Ticket CreatTicket(User temp, Bus temp1, Bookinfo bookinfo, int price) { Ticket ticket = new Ticket(); ticket.Tid = GetRandomString(12, true, true, true, false, "Tk"); ticket.Uid = temp.Uid; ticket.Bid = bookinfo.Bid; ticket.creattime = DateTime.Now.ToString(); ticket.UserName = temp.Name; ticket.UserIdCode = temp.IdCode; ticket.Start = textBox1.Text; ticket.BusCode = temp1.BusCode; ticket.End = textBox2.Text; ticket.StartTime = bookinfo.StartTime; ticket.Price = Convert.ToString(price); return(ticket); }
/// <summary> /// 模糊查询图书数 /// </summary> /// <param name="bookname">查询关键字</param> /// <param name="conn">IDbConnection(数据库连接对象)</param> /// <returns>获得满足筛选条件的图书信息</returns> public List <Bookinfo> QueryBookByName(string bookname, IDbConnection conn) { string sqlText = "select top(100) BookID, Title, Decrible from BookInfo WHERE Title LIKE '%" + bookname + "%'"; List <Bookinfo> bookinfolist = new List <Bookinfo>(); try { using (SqlDataReader result = SqlHelper.ExecuteReader(null, conn as SqlConnection, sqlText, null)) { if (result.HasRows) { while (result.Read()) { Bookinfo stbookinfo = new Bookinfo(); // 图书ID if (!result.IsDBNull(0)) { stbookinfo.BookID = result.GetGuid(0); } // 图书名字 if (!result.IsDBNull(1)) { stbookinfo.Title = result.GetString(1).Trim(); } // 图书描述 if (!result.IsDBNull(2)) { stbookinfo.Decrible = result.GetString(2).Trim(); } bookinfolist.Add(stbookinfo); } } } } catch (Exception exp) { AppException appexp = new AppException("模糊查询图书数", exp, ExceptionLevel.Error); LogManager.Log.WriteException(appexp); } return(bookinfolist); }
private void Button4_Click(object sender, EventArgs e) { using (busticketContext context = new busticketContext()) { Bookinfo temp = context.Bookinfo.FirstOrDefault(x => x.Bid == textBox1.Text); if (temp == null) { MessageBox.Show("线路不存在!", "提示"); } else { context.Bookinfo.Remove(temp); MessageBox.Show("删除成功!", "提示"); context.SaveChanges(); } } }
/// <summary> /// 根据图书ID查询图书信息 /// </summary> /// <param name="bookID">图书ID</param> /// <param name="conn">数据库连接</param> /// <returns>图书信息</returns> public Bookinfo GetBookInfoBybookid(Guid bookID, IDbConnection conn) { Bookinfo bookinfo = new Bookinfo(); try { // 图书信息查询语句 string sqlforbookinfo = "select Top(1) Title, Decrible from BookInfo where BookID = @bookID"; SqlParameter[] parameters = { new SqlParameter("@bookID", SqlDbType.UniqueIdentifier) }; parameters[0].Value = bookID; bookinfo.BookID = bookID; using (SqlDataReader result = SqlHelper.ExecuteReader(null, conn as SqlConnection, sqlforbookinfo, parameters)) { if (result.HasRows) { while (result.Read()) { // 图书名 if (!result.IsDBNull(0)) { bookinfo.Title = result.GetString(0); } // 图书描述 if (!result.IsDBNull(1)) { bookinfo.Decrible = result.GetString(1); } } } result.Close(); } } catch (Exception exp) { AppException appexp = new AppException("根据图书ID查询图书信息", exp, ExceptionLevel.Error); LogManager.Log.WriteException(appexp); } return(bookinfo); }
private void Button3_Click(object sender, EventArgs e) { using (busticketContext context = new busticketContext()) { Bookinfo temp = context.Bookinfo.FirstOrDefault(x => x.Bid == textBox1.Text); if (temp == null) { MessageBox.Show("线路不存在!", "提示"); } else { textBox2.Text = temp.Start; textBox3.Text = temp.End; textBox4.Text = temp.StartTime; textBox5.Text = temp.EndTime; textBox6.Text = temp.BusCode; textBox7.Text = Convert.ToString(temp.Count); textBox8.Text = temp.Price; } } }
public void DeleteLine(Line temp) { using (busContext context = new busContext()) { Bookinfo bookinfo = context.Bookinfo.FirstOrDefault(x => x.Lid == temp.Lid); if (bookinfo == null) { context.Remove(temp); context.SaveChanges(); MessageBox.Show("删除成功!", "提示"); } else { context.Remove(temp); context.Remove(bookinfo); context.SaveChanges(); MessageBox.Show("删除成功,使用本线路的车次也被删除!", "提示"); } } }
private void Button1_Click(object sender, EventArgs e) { using (busticketContext context = new busticketContext()) { Bookinfo bookinfo = context.Bookinfo.FirstOrDefault(x => x.Bid == textBox1.Text); if (bookinfo != null) { textBox2.Text = bookinfo.Bid; textBox3.Text = bookinfo.Start; textBox4.Text = bookinfo.End; textBox5.Text = bookinfo.StartTime; textBox6.Text = bookinfo.EndTime; textBox7.Text = bookinfo.BusCode; textBox8.Text = Convert.ToString(bookinfo.Count); textBox9.Text = bookinfo.Price; } else { MessageBox.Show("线路不存在,请输入正确的线路ID!", "提示"); } } }
private void Button2_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("确定购买本线路车票?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { using (busticketContext context = new busticketContext()) { User temp = context.User.FirstOrDefault(x => x.Id == common.id); Bookinfo bookinfo = context.Bookinfo.FirstOrDefault(x => x.Bid == textBox1.Text); if (bookinfo.Count > 0) { Ticket ticket = new Ticket(); ticket.BusCode = bookinfo.BusCode; ticket.Tid = GetRandomString(12, true, true, true, false, "Tk"); ticket.UserId = temp.Id; ticket.UserName = temp.Name; ticket.Price = bookinfo.Price; ticket.InfoId = bookinfo.Bid; ticket.Start = bookinfo.Start; ticket.StartTime = bookinfo.StartTime; ticket.End = bookinfo.End; ticket.EndTime = bookinfo.EndTime; ticket.UserIdCode = temp.IdCode; ticket.CreatTime = DateTime.Now.ToString(); context.Add(ticket); MessageBox.Show("购买成功!", "提示"); bookinfo.Count--; context.SaveChanges(); } else { MessageBox.Show("票已售完!", "提示"); } } } }
protected void Button3_Click(object sender, EventArgs e) { if (Session["user"] != null) { if (Session["type"].ToString() == null) { } else if (Session["type"].ToString() == "e") { string username = Session["user"].ToString(); string bookname = Session["name"].ToString(); Bookinfo user = new Bookinfo(username); user = bbl.selectuser(user); Bookinfo book = new Bookinfo(bookname); book = bbl.selectebook(book); Bookinfo lg = new Bookinfo(username, bookname, user.userid, book.bookid); OperationResult op = bbl.Registe(lg); if (op.ToString() == "exist") { Response.Write("记录已存在"); } else if (op.ToString() == "success") { string userName = Session["user"].ToString(); string text = user.ToString() + "加入书架:" + bookname; daysInfo da = new daysInfo(userName, DateTime.Now.ToLocalTime().ToString(), text); commentBll bal = new commentBll(); OperationResult ob = bal.Registday(da); Response.Write("成功"); } } else if (Session["type"].ToString() == "b") { string username = Session["user"].ToString(); string bookname = Session["name"].ToString(); Bookinfo user = new Bookinfo(username); user = bbl.selectuser(user); Bookinfo book = new Bookinfo(bookname); book = bbl.selectebook(book); Bookinfo lg = new Bookinfo(username, bookname, user.userid, book.bookid); OperationResult op = bbl.Regist(lg); if (op.ToString() == "exist") { Response.Write("记录已存在"); } else if (op.ToString() == "success") { Response.Write("成功"); } } } else { } }
/// <summary> /// 获取图书信息 /// </summary> protected override void ExecuteMethods() { this.bookinfo = this.GetBookInfoBybookid(this.bookguid, this.Connection); }
private void Button3_Click(object sender, EventArgs e)//BuyTicketHe() { using (busContext context = new busContext()) { var re = context.Line.Join(context.Bookinfo, a => a.Lid, o => o.Lid, (a, o) => new { a.Mid0, a.Mid1, a.Mid2, a.Start, a.End, o.Lid, o.Bid, o.BusCode, o.StartTime, o.Usetime, o.Surplus, o.Price0, o.Price1, o.Price2, o.Price3 }); for (int i = listView1.SelectedItems.Count - 1; i >= 0; i--) { ListViewItem item = listView1.SelectedItems[i]; Bookinfo bookinfo = context.Bookinfo.FirstOrDefault(q => q.Bid == item.Text); Line line = context.Line.FirstOrDefault(z => z.Lid == bookinfo.Lid); int x = 0, y = 0, price = 0; if (textBox1.Text == line.Start) { x = 1; } if (textBox1.Text == line.Mid0) { x = 2; } if (textBox1.Text == line.Mid1) { x = 3; } if (textBox1.Text == line.Mid2) { x = 4; } if (textBox2.Text == line.Mid0) { y = 2; } if (textBox2.Text == line.Mid1) { y = 3; } if (textBox2.Text == line.Mid2) { y = 4; } if (textBox2.Text == line.End) { y = 5; } int[] p = { 0, 0, 0, 0 }; p[0] = int.Parse(bookinfo.Price0); p[1] = int.Parse(bookinfo.Price1); p[2] = int.Parse(bookinfo.Price2); p[3] = int.Parse(bookinfo.Price3); while (x < y) { price += p[x - 1]; x++; } DialogResult result = MessageBox.Show("确定购买本线路车票?" + Environment.NewLine + "出发地:" + textBox1.Text + Environment.NewLine + "目的地:" + textBox2.Text + Environment.NewLine + "价格:" + price + Environment.NewLine + "购票人姓名:" + textBox3.Text + Environment.NewLine + "身份证号码:" + textBox4.Text, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { if (bookinfo.Surplus > 0) { Ticket ticket = new Ticket(); User temp = context.User.FirstOrDefault(a => a.Uid == "22221"); ticket.Tid = GetRandomString(12, true, true, true, false, "Tk"); ticket.Uid = temp.Uid; ticket.Bid = bookinfo.Bid; ticket.creattime = DateTime.Now.ToString(); ticket.UserName = textBox3.Text; ticket.UserIdCode = textBox4.Text; ticket.Start = textBox1.Text; ticket.End = textBox2.Text; ticket.StartTime = bookinfo.StartTime; ticket.Price = Convert.ToString(price); context.Ticket.Add(ticket); bookinfo.Surplus--; context.SaveChanges(); MessageBox.Show("购买成功!", "提示"); } else { MessageBox.Show("票已售完!", "提示"); } } } } }