欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#实现餐饮管理系统完整版

程序员文章站 2023-11-27 10:01:46
完整版的c#餐饮管理系统,供大家一起共同分享学习。 部分代码: dataoperator.cs using system; using system.d...

完整版的c#餐饮管理系统,供大家一起共同分享学习。

部分代码:

dataoperator.cs

using system;
using system.data;
using system.configuration;
using system.linq;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.htmlcontrols;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.xml.linq;
using system.data.sqlclient;

/// <summary>
///dataoperator 的摘要说明
/// </summary>
public class dataoperator
{
 public dataoperator()
 {
 //
 //todo: 在此处添加构造函数逻辑
 //
 }
  public static sqlconnection creatcon()
  {
    string strcon = configurationmanager.connectionstrings["connstr"].connectionstring;

    sqlconnection con = new sqlconnection(strcon);
    return con;
  }
/// 查询的数据是否已经存在
  /// </summary>
  /// <param name="sql">需要执行的sql语句</param>
  /// <returns>返回布尔值,true表示已经存在,false表示不存在</returns>
  public static bool isdata(string sql)
  {
    //创建数据库连接
    sqlconnection con = creatcon();
    //打开数据库连接
    con.open();
    //创建command对象
    sqlcommand com = new sqlcommand(sql, con);
    //获取executescalar方法所返回的值
    int ex = convert.toint32(com.executescalar());
    //关闭数据库连接
    con.close();
    //判断整型变量并返回相应的布尔值
    if (ex > 0)
    {
      return true;
    }
    else
    {
      return false;
    }


  }
  /// 执行数据库中的更新、插入、删除操作
  /// </summary>
  /// <param name="sql">需要执行的sql语句</param>
  /// <returns>返回布尔值,true表示已存在,false表示不存在</returns>
  public static bool exsql(string sql)
  {
    sqlconnection con = creatcon();
    con.open();
    sqlcommand com = new sqlcommand(sql, con);
    int rows = convert.toint32(com.executenonquery());
    if (rows > 0)
      return true;
    else
      return false;


  }
  public static string gettier(string sql) //返回指定列的值
  {
    //sqlconnection con = creatcon()
    //con.open();
    //sqlcommand cmd = new sqlcommand(sql, con);
    ////获得记录行
    //sqldatareader sdr = cmd.executereader();
    //sdr.read();
    //string str = sdr[0].tostring();
    //con.close();
    //return str;
    sqlconnection con = creatcon();
    sqldataadapter sda = new sqldataadapter(sql, con);
    dataset ds = new dataset();
    sda.fill(ds);
    string str = ds.tables[0].rows[0][0].tostring();
    return str;
  }

  public static dataset getrows(string sql)  //返回所查询表中所有数据
  {

    //创建数据库连接
    sqlconnection con = creatcon();
    //打开数据连接
    //创建dataadapter对象
    sqldataadapter sda = new sqldataadapter(sql, con);
    //创建dataset对象
    dataset ds = new dataset();
    //通过fill方法
    sda.fill(ds);
    //关闭数据库连接
    //返回dataset对象
    return ds;


  }
   
}

messagebox.cs

using system;
using system.data;
using system.configuration;
using system.linq;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.htmlcontrols;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.xml.linq;

/// <summary>
///messagebox 的摘要说明
/// </summary>
public class messagebox
{
 public messagebox()
 {
 //
 //todo: 在此处添加构造函数逻辑
 //
 }
  public static void show(string messageinfo)
  {
    httpcontext.current.response.write("<script>alert('"+messageinfo+"')</script>");
  }
  public static void show(string messageinfo, string pagepath)
  {
    httpcontext.current.response.write("<script>alert('"+messageinfo+"');location='"+pagepath+"'</script>");
  }
  public static void showpath(string pagepath)
  {
    httpcontext.current.response.write("<script>location='" + pagepath + "'</script>");
  }
}

userinformation.designer.cs

#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//   此代码由工具生成。
//   运行库版本:2.0.50727.1891
//
//   对此文件的更改可能会导致不正确的行为,并且如果
//   重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.data.linq;
using system.data.linq.mapping;
using system.linq;
using system.linq.expressions;
using system.reflection;


[system.data.linq.mapping.databaseattribute(name="menulinq")]
public partial class userinformationdatacontext : system.data.linq.datacontext
{
 
 private static system.data.linq.mapping.mappingsource mappingsource = new attributemappingsource();
 
 #region extensibility method definitions
 partial void oncreated();
 partial void insert用户信息(用户信息 instance);
 partial void update用户信息(用户信息 instance);
 partial void delete用户信息(用户信息 instance);
 partial void insert订餐信息(订餐信息 instance);
 partial void update订餐信息(订餐信息 instance);
 partial void delete订餐信息(订餐信息 instance);
 partial void insert菜样信息(菜样信息 instance);
 partial void update菜样信息(菜样信息 instance);
 partial void delete菜样信息(菜样信息 instance);
 #endregion
 
 public userinformationdatacontext() : 
  base(global::system.configuration.configurationmanager.connectionstrings["connstr"].connectionstring, mappingsource)
 {
 oncreated();
 }
 
 public userinformationdatacontext(string connection) : 
  base(connection, mappingsource)
 {
 oncreated();
 }
 
 public userinformationdatacontext(system.data.idbconnection connection) : 
  base(connection, mappingsource)
 {
 oncreated();
 }
 
 public userinformationdatacontext(string connection, system.data.linq.mapping.mappingsource mappingsource) : 
  base(connection, mappingsource)
 {
 oncreated();
 }
 
 public userinformationdatacontext(system.data.idbconnection connection, system.data.linq.mapping.mappingsource mappingsource) : 
  base(connection, mappingsource)
 {
 oncreated();
 }
 
 public system.data.linq.table<用户信息> 用户信息
 {
 get
 {
  return this.gettable<用户信息>();
 }
 }
 
 public system.data.linq.table<订餐信息> 订餐信息
 {
 get
 {
  return this.gettable<订餐信息>();
 }
 }
 
 public system.data.linq.table<菜样信息> 菜样信息
 {
 get
 {
  return this.gettable<菜样信息>();
 }
 }
}

[table(name="dbo.用户信息")]
public partial class 用户信息 : inotifypropertychanging, inotifypropertychanged
{
 
 private static propertychangingeventargs emptychangingeventargs = new propertychangingeventargs(string.empty);
 
 private int _序号;
 
 private string _用户名;
 
 private string _用户密码;
 
 private string _邮箱;
 
 private string _住址;
 
 private string _手机号;
 
  #region extensibility method definitions
  partial void onloaded();
  partial void onvalidate(system.data.linq.changeaction action);
  partial void oncreated();
  partial void on序号changing(int value);
  partial void on序号changed();
  partial void on用户名changing(string value);
  partial void on用户名changed();
  partial void on用户密码changing(string value);
  partial void on用户密码changed();
  partial void on邮箱changing(string value);
  partial void on邮箱changed();
  partial void on住址changing(string value);
  partial void on住址changed();
  partial void on手机号changing(string value);
  partial void on手机号changed();
  #endregion
 
 public 用户信息()
 {
 oncreated();
 }
 
 [column(storage="_序号", autosync=autosync.oninsert, dbtype="int not null identity", isprimarykey=true, isdbgenerated=true)]
 public int 序号
 {
 get
 {
  return this._序号;
 }
 set
 {
  if ((this._序号 != value))
  {
  this.on序号changing(value);
  this.sendpropertychanging();
  this._序号 = value;
  this.sendpropertychanged("序号");
  this.on序号changed();
  }
 }
 }
 
 [column(storage="_用户名", dbtype="nchar(10)")]
 public string 用户名
 {
 get
 {
  return this._用户名;
 }
 set
 {
  if ((this._用户名 != value))
  {
  this.on用户名changing(value);
  this.sendpropertychanging();
  this._用户名 = value;
  this.sendpropertychanged("用户名");
  this.on用户名changed();
  }
 }
 }
 
 [column(storage="_用户密码", dbtype="varchar(50)")]
 public string 用户密码
 {
 get
 {
  return this._用户密码;
 }
 set
 {
  if ((this._用户密码 != value))
  {
  this.on用户密码changing(value);
  this.sendpropertychanging();
  this._用户密码 = value;
  this.sendpropertychanged("用户密码");
  this.on用户密码changed();
  }
 }
 }
 
 [column(storage="_邮箱", dbtype="varchar(50)")]
 public string 邮箱
 {
 get
 {
  return this._邮箱;
 }
 set
 {
  if ((this._邮箱 != value))
  {
  this.on邮箱changing(value);
  this.sendpropertychanging();
  this._邮箱 = value;
  this.sendpropertychanged("邮箱");
  this.on邮箱changed();
  }
 }
 }
 
 [column(storage="_住址", dbtype="varchar(50)")]
 public string 住址
 {
 get
 {
  return this._住址;
 }
 set
 {
  if ((this._住址 != value))
  {
  this.on住址changing(value);
  this.sendpropertychanging();
  this._住址 = value;
  this.sendpropertychanged("住址");
  this.on住址changed();
  }
 }
 }
 
 [column(storage="_手机号", dbtype="varchar(50)")]
 public string 手机号
 {
 get
 {
  return this._手机号;
 }
 set
 {
  if ((this._手机号 != value))
  {
  this.on手机号changing(value);
  this.sendpropertychanging();
  this._手机号 = value;
  this.sendpropertychanged("手机号");
  this.on手机号changed();
  }
 }
 }
 
 public event propertychangingeventhandler propertychanging;
 
 public event propertychangedeventhandler propertychanged;
 
 protected virtual void sendpropertychanging()
 {
 if ((this.propertychanging != null))
 {
  this.propertychanging(this, emptychangingeventargs);
 }
 }
 
 protected virtual void sendpropertychanged(string propertyname)
 {
 if ((this.propertychanged != null))
 {
  this.propertychanged(this, new propertychangedeventargs(propertyname));
 }
 }
}

[table(name="dbo.订餐信息")]
public partial class 订餐信息 : inotifypropertychanging, inotifypropertychanged
{
 
 private static propertychangingeventargs emptychangingeventargs = new propertychangingeventargs(string.empty);
 
 private int _序号;
 
 private system.nullable<int> _菜样编号;
 
 private string _菜名;
 
 private string _菜样图片;
 
 private system.nullable<int> _份数;
 
 private system.nullable<int> _菜价;
 
 private system.nullable<int> _应付金额;
 
 private string _订餐日期;
 
 private string _用户名;
 
  #region extensibility method definitions
  partial void onloaded();
  partial void onvalidate(system.data.linq.changeaction action);
  partial void oncreated();
  partial void on序号changing(int value);
  partial void on序号changed();
  partial void on菜样编号changing(system.nullable<int> value);
  partial void on菜样编号changed();
  partial void on菜名changing(string value);
  partial void on菜名changed();
  partial void on菜样图片changing(string value);
  partial void on菜样图片changed();
  partial void on份数changing(system.nullable<int> value);
  partial void on份数changed();
  partial void on菜价changing(system.nullable<int> value);
  partial void on菜价changed();
  partial void on应付金额changing(system.nullable<int> value);
  partial void on应付金额changed();
  partial void on订餐日期changing(string value);
  partial void on订餐日期changed();
  partial void on用户名changing(string value);
  partial void on用户名changed();
  #endregion
 
 public 订餐信息()
 {
 oncreated();
 }
 
 [column(storage="_序号", autosync=autosync.oninsert, dbtype="int not null identity", isprimarykey=true, isdbgenerated=true)]
 public int 序号
 {
 get
 {
  return this._序号;
 }
 set
 {
  if ((this._序号 != value))
  {
  this.on序号changing(value);
  this.sendpropertychanging();
  this._序号 = value;
  this.sendpropertychanged("序号");
  this.on序号changed();
  }
 }
 }
 
 [column(storage="_菜样编号", dbtype="int")]
 public system.nullable<int> 菜样编号
 {
 get
 {
  return this._菜样编号;
 }
 set
 {
  if ((this._菜样编号 != value))
  {
  this.on菜样编号changing(value);
  this.sendpropertychanging();
  this._菜样编号 = value;
  this.sendpropertychanged("菜样编号");
  this.on菜样编号changed();
  }
 }
 }
 
 [column(storage="_菜名", dbtype="nchar(10)")]
 public string 菜名
 {
 get
 {
  return this._菜名;
 }
 set
 {
  if ((this._菜名 != value))
  {
  this.on菜名changing(value);
  this.sendpropertychanging();
  this._菜名 = value;
  this.sendpropertychanged("菜名");
  this.on菜名changed();
  }
 }
 }
 
 [column(storage="_菜样图片", dbtype="nchar(30)")]
 public string 菜样图片
 {
 get
 {
  return this._菜样图片;
 }
 set
 {
  if ((this._菜样图片 != value))
  {
  this.on菜样图片changing(value);
  this.sendpropertychanging();
  this._菜样图片 = value;
  this.sendpropertychanged("菜样图片");
  this.on菜样图片changed();
  }
 }
 }
 
 [column(storage="_份数", dbtype="int")]
 public system.nullable<int> 份数
 {
 get
 {
  return this._份数;
 }
 set
 {
  if ((this._份数 != value))
  {
  this.on份数changing(value);
  this.sendpropertychanging();
  this._份数 = value;
  this.sendpropertychanged("份数");
  this.on份数changed();
  }
 }
 }
 
 [column(storage="_菜价", dbtype="int")]
 public system.nullable<int> 菜价
 {
 get
 {
  return this._菜价;
 }
 set
 {
  if ((this._菜价 != value))
  {
  this.on菜价changing(value);
  this.sendpropertychanging();
  this._菜价 = value;
  this.sendpropertychanged("菜价");
  this.on菜价changed();
  }
 }
 }
 
 [column(storage="_应付金额", dbtype="int")]
 public system.nullable<int> 应付金额
 {
 get
 {
  return this._应付金额;
 }
 set
 {
  if ((this._应付金额 != value))
  {
  this.on应付金额changing(value);
  this.sendpropertychanging();
  this._应付金额 = value;
  this.sendpropertychanged("应付金额");
  this.on应付金额changed();
  }
 }
 }
 
 [column(storage="_订餐日期", dbtype="nvarchar(50)")]
 public string 订餐日期
 {
 get
 {
  return this._订餐日期;
 }
 set
 {
  if ((this._订餐日期 != value))
  {
  this.on订餐日期changing(value);
  this.sendpropertychanging();
  this._订餐日期 = value;
  this.sendpropertychanged("订餐日期");
  this.on订餐日期changed();
  }
 }
 }
 
 [column(storage="_用户名", dbtype="nchar(15)")]
 public string 用户名
 {
 get
 {
  return this._用户名;
 }
 set
 {
  if ((this._用户名 != value))
  {
  this.on用户名changing(value);
  this.sendpropertychanging();
  this._用户名 = value;
  this.sendpropertychanged("用户名");
  this.on用户名changed();
  }
 }
 }
 
 public event propertychangingeventhandler propertychanging;
 
 public event propertychangedeventhandler propertychanged;
 
 protected virtual void sendpropertychanging()
 {
 if ((this.propertychanging != null))
 {
  this.propertychanging(this, emptychangingeventargs);
 }
 }
 
 protected virtual void sendpropertychanged(string propertyname)
 {
 if ((this.propertychanged != null))
 {
  this.propertychanged(this, new propertychangedeventargs(propertyname));
 }
 }
}

[table(name="dbo.菜样信息")]
public partial class 菜样信息 : inotifypropertychanging, inotifypropertychanged
{
 
 private static propertychangingeventargs emptychangingeventargs = new propertychangingeventargs(string.empty);
 
 private int _序号;
 
 private int _菜样编号;
 
 private string _菜名;
 
 private string _菜样类型;
 
 private string _菜样图片;
 
 private string _厨师;
 
 private system.nullable<int> _现在价格;
 
 private system.nullable<int> _优惠价格;
 
 private string _创菜时间;
 
  #region extensibility method definitions
  partial void onloaded();
  partial void onvalidate(system.data.linq.changeaction action);
  partial void oncreated();
  partial void on序号changing(int value);
  partial void on序号changed();
  partial void on菜样编号changing(int value);
  partial void on菜样编号changed();
  partial void on菜名changing(string value);
  partial void on菜名changed();
  partial void on菜样类型changing(string value);
  partial void on菜样类型changed();
  partial void on菜样图片changing(string value);
  partial void on菜样图片changed();
  partial void on厨师changing(string value);
  partial void on厨师changed();
  partial void on现在价格changing(system.nullable<int> value);
  partial void on现在价格changed();
  partial void on优惠价格changing(system.nullable<int> value);
  partial void on优惠价格changed();
  partial void on创菜时间changing(string value);
  partial void on创菜时间changed();
  #endregion
 
 public 菜样信息()
 {
 oncreated();
 }
 
 [column(storage="_序号", autosync=autosync.oninsert, dbtype="int not null identity", isprimarykey=true, isdbgenerated=true)]
 public int 序号
 {
 get
 {
  return this._序号;
 }
 set
 {
  if ((this._序号 != value))
  {
  this.on序号changing(value);
  this.sendpropertychanging();
  this._序号 = value;
  this.sendpropertychanged("序号");
  this.on序号changed();
  }
 }
 }
 
 [column(storage="_菜样编号", dbtype="int not null")]
 public int 菜样编号
 {
 get
 {
  return this._菜样编号;
 }
 set
 {
  if ((this._菜样编号 != value))
  {
  this.on菜样编号changing(value);
  this.sendpropertychanging();
  this._菜样编号 = value;
  this.sendpropertychanged("菜样编号");
  this.on菜样编号changed();
  }
 }
 }
 
 [column(storage="_菜名", dbtype="nchar(10)")]
 public string 菜名
 {
 get
 {
  return this._菜名;
 }
 set
 {
  if ((this._菜名 != value))
  {
  this.on菜名changing(value);
  this.sendpropertychanging();
  this._菜名 = value;
  this.sendpropertychanged("菜名");
  this.on菜名changed();
  }
 }
 }
 
 [column(storage="_菜样类型", dbtype="nchar(10)")]
 public string 菜样类型
 {
 get
 {
  return this._菜样类型;
 }
 set
 {
  if ((this._菜样类型 != value))
  {
  this.on菜样类型changing(value);
  this.sendpropertychanging();
  this._菜样类型 = value;
  this.sendpropertychanged("菜样类型");
  this.on菜样类型changed();
  }
 }
 }
 
 [column(storage="_菜样图片", dbtype="nvarchar(50)")]
 public string 菜样图片
 {
 get
 {
  return this._菜样图片;
 }
 set
 {
  if ((this._菜样图片 != value))
  {
  this.on菜样图片changing(value);
  this.sendpropertychanging();
  this._菜样图片 = value;
  this.sendpropertychanged("菜样图片");
  this.on菜样图片changed();
  }
 }
 }
 
 [column(storage="_厨师", dbtype="nchar(15)")]
 public string 厨师
 {
 get
 {
  return this._厨师;
 }
 set
 {
  if ((this._厨师 != value))
  {
  this.on厨师changing(value);
  this.sendpropertychanging();
  this._厨师 = value;
  this.sendpropertychanged("厨师");
  this.on厨师changed();
  }
 }
 }
 
 [column(storage="_现在价格", dbtype="int")]
 public system.nullable<int> 现在价格
 {
 get
 {
  return this._现在价格;
 }
 set
 {
  if ((this._现在价格 != value))
  {
  this.on现在价格changing(value);
  this.sendpropertychanging();
  this._现在价格 = value;
  this.sendpropertychanged("现在价格");
  this.on现在价格changed();
  }
 }
 }
 
 [column(storage="_优惠价格", dbtype="int")]
 public system.nullable<int> 优惠价格
 {
 get
 {
  return this._优惠价格;
 }
 set
 {
  if ((this._优惠价格 != value))
  {
  this.on优惠价格changing(value);
  this.sendpropertychanging();
  this._优惠价格 = value;
  this.sendpropertychanged("优惠价格");
  this.on优惠价格changed();
  }
 }
 }
 
 [column(storage="_创菜时间", dbtype="nchar(20)")]
 public string 创菜时间
 {
 get
 {
  return this._创菜时间;
 }
 set
 {
  if ((this._创菜时间 != value))
  {
  this.on创菜时间changing(value);
  this.sendpropertychanging();
  this._创菜时间 = value;
  this.sendpropertychanged("创菜时间");
  this.on创菜时间changed();
  }
 }
 }
 
 public event propertychangingeventhandler propertychanging;
 
 public event propertychangedeventhandler propertychanged;
 
 protected virtual void sendpropertychanging()
 {
 if ((this.propertychanging != null))
 {
  this.propertychanging(this, emptychangingeventargs);
 }
 }
 
 protected virtual void sendpropertychanged(string propertyname)
 {
 if ((this.propertychanged != null))
 {
  this.propertychanged(this, new propertychangedeventargs(propertyname));
 }
 }
}
#pragma warning restore 1591

源码下载:c#实现餐饮管理系统

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。