介绍+展示
系统环境:Windows
开发工具:Visual Studio 2019
数据库:SQL Server2008
简介: Windows系统下的winform窗体应用程序,采用三层架构开发方式,使用C#语言开发的一个进销存管理系统
数据库配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<appSettings>
<add key="ConnectionString" value="data source=.;initial catalog=Purchase and sale;user id=Sa;pwd=数据库密码" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
sql脚本
USE [Purchase and sale]
GO
/****** Object: Table [dbo].[Manufactor] Script Date: 08/16/2023 23:27:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Manufactor](
[cjid] [int] IDENTITY(1,1) NOT NULL,
[cjmc] [nchar](50) NULL,
[cjfzr] [nchar](50) NULL,
[cjdh] [int] NULL,
[cjdz] [nchar](50) NULL,
[kcid] [int] NULL,
CONSTRAINT [PK_Manufactor] PRIMARY KEY CLUSTERED
(
[cjid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Stock] Script Date: 08/16/2023 23:27:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Stock](
[kcid] [int] IDENTITY(1,1) NOT NULL,
[kcmc] [nchar](20) NULL,
[spmc] [nchar](10) NULL,
[kcsl] [int] NULL,
[kcbj] [int] NULL,
[spid] [int] NULL,
[cjid] [int] NULL,
CONSTRAINT [PK_Stocks] PRIMARY KEY CLUSTERED
(
[kcid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Commodity] Script Date: 08/16/2023 23:27:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Commodity](
[spid] [int] IDENTITY(1,1) NOT NULL,
[spmc] [nchar](10) NULL,
[splx] [nchar](10) NULL,
[spjg] [nchar](10) NULL,
[cjid] [int] NULL,
[xsid] [int] NULL,
[jhid] [int] NULL,
[zkl] [nchar](10) NULL,
[zksj] [datetime] NULL,
[kcid] [int] NULL,
CONSTRAINT [PK_Commodity] PRIMARY KEY CLUSTERED
(
[spid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Purchases] Script Date: 08/16/2023 23:27:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Purchases](
[jhid] [int] IDENTITY(1,1) NOT NULL,
[jhr] [nchar](10) NULL,
[jhsl] [int] NULL,
[jhjg] [decimal](18, 0) NULL,
[jhsj] [datetime] NULL,
[spid] [int] NULL,
[cjid] [int] NULL,
CONSTRAINT [PK_Purchase] PRIMARY KEY CLUSTERED
(
[jhid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Order] Script Date: 08/16/2023 23:27:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Order](
[ddid] [int] IDENTITY(1,1) NOT NULL,
[sppm] [nchar](30) NULL,
[sl] [int] NULL,
[je] [decimal](18, 0) NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[sales] Script Date: 08/16/2023 23:27:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[sales](
[xsid] [int] IDENTITY(1,1) NOT NULL,
[xsr] [nchar](10) NULL,
[xsdj] [nchar](10) NULL,
[xssl] [nchar](10) NULL,
[xsrq] [datetime] NULL,
[xsyl] [varchar](50) NULL,
[spid] [int] NULL,
CONSTRAINT [PK_sales] PRIMARY KEY CLUSTERED
(
[xsid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Einformation] Script Date: 08/16/2023 23:27:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Einformation](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nchar](10) NOT NULL,
[sex] [nchar](10) NULL,
[age] [nchar](10) NULL,
[account] [int] NOT NULL,
[pass] [varchar](50) NOT NULL,
[wq] [nchar](100) NULL,
[yq] [nchar](100) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Administrators] Script Date: 08/16/2023 23:27:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Administrators](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) NOT NULL,
[sex] [varchar](50) NULL,
[age] [int] NULL,
[account] [int] NOT NULL,
[pass] [varchar](50) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: ForeignKey [FK_Commodity_Manufactor] Script Date: 08/16/2023 23:27:19 ******/
ALTER TABLE [dbo].[Commodity] WITH CHECK ADD CONSTRAINT [FK_Commodity_Manufactor] FOREIGN KEY([cjid])
REFERENCES [dbo].[Manufactor] ([cjid])
GO
ALTER TABLE [dbo].[Commodity] CHECK CONSTRAINT [FK_Commodity_Manufactor]
GO
/****** Object: ForeignKey [FK_Commodity_Stocks] Script Date: 08/16/2023 23:27:19 ******/
ALTER TABLE [dbo].[Commodity] WITH CHECK ADD CONSTRAINT [FK_Commodity_Stocks] FOREIGN KEY([kcid])
REFERENCES [dbo].[Stock] ([kcid])
GO
ALTER TABLE [dbo].[Commodity] CHECK CONSTRAINT [FK_Commodity_Stocks]
GO
/****** Object: ForeignKey [FK_Manufactor_Stocks] Script Date: 08/16/2023 23:27:19 ******/
ALTER TABLE [dbo].[Manufactor] WITH CHECK ADD CONSTRAINT [FK_Manufactor_Stocks] FOREIGN KEY([kcid])
REFERENCES [dbo].[Stock] ([kcid])
GO
ALTER TABLE [dbo].[Manufactor] CHECK CONSTRAINT [FK_Manufactor_Stocks]
GO
/****** Object: ForeignKey [FK_Purchase_Commodity] Script Date: 08/16/2023 23:27:19 ******/
ALTER TABLE [dbo].[Purchases] WITH CHECK ADD CONSTRAINT [FK_Purchase_Commodity] FOREIGN KEY([spid])
REFERENCES [dbo].[Commodity] ([spid])
GO
ALTER TABLE [dbo].[Purchases] CHECK CONSTRAINT [FK_Purchase_Commodity]
GO
/****** Object: ForeignKey [FK_Stocks_Commodity] Script Date: 08/16/2023 23:27:19 ******/
ALTER TABLE [dbo].[Stock] WITH CHECK ADD CONSTRAINT [FK_Stocks_Commodity] FOREIGN KEY([spid])
REFERENCES [dbo].[Commodity] ([spid])
GO
ALTER TABLE [dbo].[Stock] CHECK CONSTRAINT [FK_Stocks_Commodity]
GO
/****** Object: ForeignKey [FK_Stocks_Manufactor] Script Date: 08/16/2023 23:27:19 ******/
ALTER TABLE [dbo].[Stock] WITH CHECK ADD CONSTRAINT [FK_Stocks_Manufactor] FOREIGN KEY([cjid])
REFERENCES [dbo].[Manufactor] ([cjid])
GO
ALTER TABLE [dbo].[Stock] CHECK CONSTRAINT [FK_Stocks_Manufactor]
GO
/****** Object: ForeignKey [FK_Stocks_Manufactor1] Script Date: 08/16/2023 23:27:19 ******/
ALTER TABLE [dbo].[Stock] WITH CHECK ADD CONSTRAINT [FK_Stocks_Manufactor1] FOREIGN KEY([cjid])
REFERENCES [dbo].[Manufactor] ([cjid])
GO
ALTER TABLE [dbo].[Stock] CHECK CONSTRAINT [FK_Stocks_Manufactor1]
GO
链接:https://pan.baidu.com/s/1QrY0bE560OYgxpzzInWc3A
提取码:1234
DbUtility
数据库工具类
using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;namespace DbUtility
{
public abstract class SqlHelp
{
protected static string connectionString = @ConfigurationManager.AppSettings["ConnectionString"];public SqlHelp()
{
}/// <summary>
/// 执行SQL语句,返回影响的记录数
/// </summary>
/// <param name="SQLString">SQL语句</param>
/// <returns>影响的记录数</returns>
public static int ExecuteSql(string SQLString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand(SQLString, connection))
{
try
{
connection.Open();
int rows = cmd.ExecuteNonQuery();
return rows;
}
catch (System.Data.SqlClient.SqlException E)
{
connection.Close();
throw new Exception(E.Message);
}
}
}
}/// <summary>
/// 执行查询语句,返回DataSet
/// </summary>
/// <param name="SQLString">查询语句</param>
/// <returns>DataSet</returns>
public static DataSet Query(string SQLString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
connection.Open();
SqlDataAdapter command = new SqlDataAdapter(SQLString, connection);
command.Fill(ds, "ds");
}
catch (System.Data.SqlClient.SqlException ex)
{
throw new Exception(ex.Message);
}
return ds;
}
}/// <summary>
/// 执行多条SQL语句,实现数据库事务。
/// </summary>
/// <param name="SQLStringList">多条SQL语句</param>
public static void ExecuteSqlTran(List<string> SQLStringList)
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
SqlTransaction tx = conn.BeginTransaction();
cmd.Transaction = tx;
try
{
for (int n = 0; n < SQLStringList.Count; n++)
{
string strsql = SQLStringList[n].ToString();
if (strsql.Trim().Length > 1)
{
cmd.CommandText = strsql;
cmd.ExecuteNonQuery();
}
}
tx.Commit();
}
catch (System.Data.SqlClient.SqlException E)
{
tx.Rollback();
throw new Exception(E.Message);
}
}
}/// <summary>
/// 执行查询语句,返回SqlDataReader
/// </summary>
/// <param name="strSQL">查询语句</param>
/// <returns>SqlDataReader</returns>
public static SqlDataReader ExecuteReader(string strSQL)
{
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(strSQL, connection);
try
{
connection.Open();
SqlDataReader myReader = cmd.ExecuteReader();
return myReader;
}
catch (System.Data.SqlClient.SqlException e)
{
throw new Exception(e.Message);
}}
}
}
Purchase and sale层
DAL层
BLLC层
界面展示
登录界面
主界面
员工管理
基础信息管理
进货管理
库存管理
销售管理
设置
重新登录
本文来自博客园,作者:hellowworld!,转载请注明原文链接:https://www.cnblogs.com/zhangsai/p/17636441.html
posted on 2023-08-16 22:51 hellowworld! 阅读(43) 评论(0) 编辑 收藏 举报