C\#슈퍼마켓 수금 시스템 디자인
1.로그 인 인터페이스
코드 는 다음 과 같 습 니 다:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace
{
public partial class denglu : Form
{
public denglu()
{
InitializeComponent();
}
model db = new model(); //
private void button1_Click(object sender, EventArgs e)
{
string strConn = "Data Source=.;Initial Catalog=shopInfo;Integrated Security=True"; //
SqlConnection Connection = new SqlConnection(strConn);
try
{
string sqlStr = "select userName,userPassword from register where userName=@userName"; //
DataSet ds = new DataSet();
Connection.ConnectionString = Connection.ConnectionString;
Connection.Open();
SqlCommand cmd = new SqlCommand(sqlStr, Connection);
cmd.Parameters.Add(new SqlParameter("@userName", SqlDbType.VarChar, 30)); //
cmd.Parameters["@userName"].Value = userName.Text; // user
SqlDataReader dater = cmd.ExecuteReader();
if (userName.Text.Trim() == "") // user
{
MessageBox.Show( " !");
}
else if (passWord.Text.Trim() == "") //
{
MessageBox.Show( " !");
}
else if (!dater.Read()) // dater ,
{
MessageBox.Show( " !");
userName.Text = "";
passWord.Text = "";
}
else if (dater["userPassWord"].ToString().Trim() == passWord.Text.Trim()) //
{
MessageBox.Show( " !");
userName.Text = "";
passWord.Text = "";
caozuoyemain frm = new caozuoyemain();
frm.ShowDialog();
}
else
{
MessageBox.Show(" !"); //
userName.Text = "";
passWord.Text = "";
}
}
catch (Exception)
{
throw; //
}
finally
{
Connection.Close(); //
}
}
private void label4_Click(object sender, EventArgs e)
{
zhuce fra = new zhuce();
fra.ShowDialog();
}
private void label6_Click(object sender, EventArgs e)
{
zhaohuimima fra = new zhaohuimima();
fra.ShowDialog();
}
private void denglu_Load(object sender, EventArgs e)
{
}
}
}
2.조작 인터페이스:코드 는 다음 과 같 습 니 다:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace
{
public partial class caozuoyemain : Form
{
public caozuoyemain()
{
InitializeComponent();
}
public double totalPrice;//
public double total; //
public double shijijin;//
public double yingzhao;//
public string mingcheng;//
public double shuliang;//
public double jiage;//
public int i = 0; // id
model db = new model(); //
public void fanli() //
{
if (jiage * shuliang < 600 && jiage * shuliang > 300)
{
totalPrice = jiage * shuliang - 100;
}
else
{
totalPrice = jiage * shuliang;
}
}
private void confirm_Click(object sender, EventArgs e) //
{
totalPrice = 0; //
jiage = Convert.ToDouble(price.Text);
shuliang = Convert.ToDouble(number.Text); //
switch (jisuanfangshi.SelectedIndex)
{
case 0:
totalPrice = jiage * shuliang;
break;
case 1:
totalPrice = jiage * shuliang*0.8;
break;
case 2:
fanli(); //
break;
}
total = totalPrice + total; //
zongjine.Text = total.ToString();// ,
i++; // id 1,
db.dbcon();
try
{
string insertInfo = "insert wupin values('" + i.ToString() + "','" + tradeName.Text + "','" + price.Text + "','" +
number.Text + "','" + jisuanfangshi.Text + "','" + totalPrice.ToString() + "')";
db.dbInsert(insertInfo);
string selstr = "select top "+i+" * from wupin order by ID desc";
db.dbFill(selstr);
dataGridView1.DataSource = db.dt;
}
catch (Exception)
{
MessageBox.Show(" , , ");
}
}
private void caozuoyemain_Load(object sender, EventArgs e)
{
db.dbcon();
string qingkong = "TRUNCATE TABLE wupin";
db.dbInsert(qingkong);
jisuanfangshi.SelectedIndex = 0;
}
private void jiesuan_Click(object sender, EventArgs e)
{
shijijin = Convert.ToDouble(shishoujine.Text);
yingzhao=Convert.ToDouble(zongjine.Text) ;
yingzhao = shijijin - total;
zhaojine.Text = yingzhao.ToString()+" ";
}
private void resetting_Click(object sender, EventArgs e)
{
tradeName.Text = "";
price.Text = "";
number.Text = "";
}
}
}
3.수금 원 등록 창:코드 는 다음 과 같 습 니 다:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace
{
public partial class zhuce : Form
{
public zhuce()
{
InitializeComponent();
}
public string sexValue; //
model db = new model(); //
private bool testuserName(string strUsername) //
{
bool strResult;//
Regex exStrUserName = new Regex(@"^[a-zA-Z][a-zA-Z0-9]{3,8}$");
//
if (strResult = exStrUserName.Match(strUsername).Success)
{
yonghuming_test.Text = "✔";
}
else
{
MessageBox.Show(" 3―6 , ");
}
return strResult;
}
private bool testPassWord(string strUsername) //
{
bool strResult;//
Regex exStrUserName = new Regex(@"^[\w\-~!@#$%^&*()+{}[ \]:]{6,16}");
//
if (strResult = exStrUserName.Match(strUsername).Success)
{
mima_test.Text = "✔";
}
else
{
mima_test.Text = "✘";
MessageBox.Show(" 6―16 ");
}
return strResult;
}
private bool testName(string strUsername) //
{
bool strResult;//
Regex exStrUserName = new Regex(@"^([a-zA-Z0-9\u4e00-\u9fa5\・]{2,3})$");
//
if (strResult = exStrUserName.Match(strUsername).Success)
{
name_test.Text = "✔";
}
else
{
name_test.Text = "✘";
MessageBox.Show(" , ");
}
if (name_text.Text == " " || name_text.Text == " " || name_text.Text == " ")
{
name_test.Text = "✘";
MessageBox.Show(" , ");
}
return strResult;
}
private bool testPhonnumber(string strUsername) //
{
bool strResult;//
Regex exStrUserName = new Regex(@"^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$");
//
if (strResult = exStrUserName.Match(strUsername).Success)
{
phonnumber_test.Text = "✔";
}
else
{
phonnumber_test.Text = "✘";
MessageBox.Show(" ");
}
return strResult;
}
private void nan_rb_CheckedChanged(object sender, EventArgs e) //
{
sexValue = nan_rb.Text;
}
private void nv_rb_CheckedChanged(object sender, EventArgs e)
{
sexValue = nv_rb.Text;
}
private void zhuce_bt_Click(object sender, EventArgs e) //
{
db.dbcon();
try
{
string insertInfo = "insert register values('" + username_text.Text + "','" + password_text.Text+ "','" + name_text.Text+
"','" + sexValue + "','" + phonnumber_text.Text + "')";
db.dbInsert(insertInfo);
DialogResult dr=MessageBox.Show(" , "," ",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
if (dr == DialogResult.OK)
{
this.Close();
denglu fra = new denglu();
fra.ShowDialog();
}
else if (dr == DialogResult.Cancel)
{
this.Close();
}
}
catch (Exception)
{
MessageBox.Show(" , , ");
}
}
private void username_text_Leave(object sender, EventArgs e) //
{
if (username_text.Text == "")
{
MessageBox.Show(" ");
}
else
{
testuserName(username_text.Text);
}
}
private void password_text_Leave(object sender, EventArgs e)//
{
if (password_text.Text == "")
{
MessageBox.Show(" ");
}
else
{
testPassWord(password_text.Text);
}
}
private void name_text_Leave(object sender, EventArgs e)//
{
if (name_text.Text == "")
{
MessageBox.Show(" ");
}
else
{
testName(name_text.Text);
}
}
private void phonnumber_text_Leave(object sender, EventArgs e)//
{
if (phonnumber_text.Text == "")
{
MessageBox.Show(" ");
}
else
{
testPhonnumber(phonnumber_text.Text);
}
}
private void chongzhi_bt_Click(object sender, EventArgs e) //
{
username_text.Text = "";
phonnumber_text.Text = "";
name_text.Text = "";
phonnumber_text.Text = "";
}
private void quxiao_bt_Click(object sender, EventArgs e)//
{
this.Close();
}
private void zhuce_Load(object sender, EventArgs e)
{
}
}
}
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
WebView2를 Visual Studio 2017 Express에서 사용할 수 있을 때까지Evergreen .Net Framework SDK 4.8 VisualStudio2017에서 NuGet을 사용하기 때문에 패키지 관리 방법을 packages.config 대신 PackageReference를 사용해야...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.