C# 手机销售系统
using System; using System.Data; using System.Data.SqlClient; using System.Collections; namespace mobilesale { /// <summary> /// DataBL 的摘要说明。 /// </summary> public class DataBL { public DataBL() { // // TODO: 在此处添加构造函数逻辑 // } public static SqlConnection getConn() { SqlConnection sqlCon= new SqlConnection("server=.;Integrated Security=SSPI;Database=MTSSystem"); return sqlCon; } public static DataTable selectMobile() { SqlConnection con=DataBL.getConn(); String strSelect="select mobileModelID as '手机编号',mobileModel as '手机型号',mobileFactory as '手机厂家',totalPrice as '手机全价',maxDisccunt as '最大折扣' from mobileModel"; SqlDataAdapter adapter=new SqlDataAdapter(strSelect,con); DataTable tab=new DataTable(); adapter.Fill(tab); return tab; } public static DataTable selectSales() { SqlConnection con=DataBL.getConn(); String strSelect="select saleID as '营业员编号',saleName as '姓名',salesVolume as '销售额' from mobileSales"; SqlDataAdapter adapter=new SqlDataAdapter(strSelect,con); DataTable tab=new DataTable(); adapter.Fill(tab); return tab; } public static ArrayList selectSaleNames() { SqlConnection con=DataBL.getConn(); String strSelect="select saleName as '姓名'from mobileSales"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); SqlDataReader reader=cmd.ExecuteReader(); ArrayList data=new ArrayList(); while(reader.Read()) { data.Add(reader.GetString(0)); } con.Close(); return data; } public static ArrayList selectMobileModel() { SqlConnection con=DataBL.getConn(); String strSelect="select mobileModel as '手机型号'from mobileModel"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); SqlDataReader reader=cmd.ExecuteReader(); ArrayList data=new ArrayList(); while(reader.Read()) { data.Add(reader.GetValue(0)); } con.Close(); return data; } public static ArrayList selectDisccunt(string mobileModel) { SqlConnection con=DataBL.getConn(); String strSelect="select maxDisccunt from mobileModel where mobileModel='"+mobileModel+"'"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); int maxDisccunt=Int32.Parse( cmd.ExecuteScalar().ToString()); con.Close(); ArrayList data=new ArrayList(); for(int i=maxDisccunt;i<=100;i++) { data.Add(i); } return data; } public static String setPrice(string mobileModel,string count,string disccunt) { SqlConnection con=DataBL.getConn(); String strSelect="select totalprice from mobileModel where mobileModel='"+mobileModel+"'"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); int maxDisccunt=Int32.Parse( cmd.ExecuteScalar().ToString()); con.Close(); return (maxDisccunt*Int32.Parse(count)*Int32.Parse(disccunt)/100).ToString(); } public static int insertOrder(string saleName,string mobileModel,string customer,string IDCardNo,string amount ,string price) { SqlConnection con=DataBL.getConn(); String strSelect="select saleID from mobileSales where saleName='"+saleName+"'"; SqlCommand cmd=new SqlCommand(strSelect,con); con.Open(); int saleId=Int32.Parse( cmd.ExecuteScalar().ToString()); con.Close(); strSelect="select mobileModelID from mobileModel where mobileModel='"+mobileModel+"'"; cmd=new SqlCommand(strSelect,con); con.Open(); int mobileModelID=Int32.Parse( cmd.ExecuteScalar().ToString()); con.Close(); string strInsert ="insert into mobileOrder values ('"+customer+"','"+IDCardNo+"',"+saleId+","+mobileModelID+","+Int32.Parse(amount)+","+Int32.Parse(price)+",'"+DateTime.Now.ToString()+"')"; cmd=new SqlCommand(strInsert,con); con.Open(); return cmd.ExecuteNonQuery(); con.Close(); } } }
- 1
- Laurencee2012-06-11内容太少了 如果内容全面一些就好了
- jackliy2011-09-26这个系统的功能太小了
- 粉丝: 10
- 资源: 60
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助