超市收银系统(流程图+摘要+任务书+开题报告+ER图+源程序) 第13页
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.SqlServerCe;//由于数据库原因,所以选择了SqlServerCe Compact
namespace SuperDesign
{
public partial class Addmember : Form
{
public Addmember()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int memberid = int.Parse(this.memid.Text);
string membername = this.memname.Text;
float total = float.Parse(this.total.Text);
string insertSql = "INSERT INTO member (memberid, membername, total) VALUES ("+memberid +", '"+membername+"' ,"+total+")";//插入会员
string connectionString =
@"Data Source=|DataDirectory|\SuperMarket.sdf;Password=123456";
using (System.Data.SqlServerCe.SqlCeConnection conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString))//连接数据库
{
SqlCeCommand command = new SqlCeCommand(insertSql, conn);
conn.Open();//打开数据库
int rowReturn = command.ExecuteNonQuery();//执行cmd
flaglable.Text = "insert ok" + rowReturn;
}
}
private void button2_Click(object sender, EventArgs e)
{
int memberid = int.Parse(this.memid.Text);
string deleteSql = "DELETE [member] WHERE memberid = "+memberid;//删除会员
string connectionString =
@"Data Source=|DataDirectory|\SuperMarket.sdf;Password=123456";
using (System.Data.SqlServerCe.SqlCeConnection conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString))
{
SqlCeCommand command = new SqlCeCommand(deleteSql, conn);
conn.Open();
int rowReturn = command.ExecuteNonQuery();
flaglable.Text = "delete ok" + rowReturn;
}
}
}
}
/********************************************************************
* 作 者: 王 宇
* 创建日期:2008.05.01
* 描 述:管理员向数据库中添加商品的具体信息
* 名 称:添加商品
* ********************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.SqlServerCe;
namespace SuperDesign
{
public partial class AddProduct : Form
{
public AddProduct()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int productid = int.Parse(this.productid.Text);
string productname = this.productname.Text;
string unit = this.unit.Text;
int number = int.Parse(this.number.Text);
float priceperunit = float.Parse(this.priceperunit.Text);
fl www.lwfree.com productname + "'" + "," + "'"+unit + "'"+ "," + number + "," + priceperunit + "," + total + ")";
string connectionString =
@"Data Source=|DataDirectory|\SuperMarket.sdf;Password=123456";
using (System.Data.SqlServerCe.SqlCeConnection conn = new System.Data.SqlServerCe.SqlCeConnection(connectionString))
{
SqlCeCommand command = new qlCeCommand(insertSql,conn);
conn.Open();
int rowReturn = command.ExecuteNonQuery();
<< 上一页 [11] [12] [13] [14] 下一页