国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#超市收銀系統(tǒng)設(shè)計(jì)

2019-10-29 21:09:18
字體:
供稿:網(wǎng)友

本文實(shí)例為大家分享了C#超市收銀系統(tǒng)設(shè)計(jì)的具體代碼,供大家參考,具體內(nèi)容如下

1.登錄界面

C#收銀系統(tǒng),C#收銀系統(tǒng)設(shè)計(jì),C#超市收銀系統(tǒng)

代碼如下:

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 夢(mèng)之翼小組項(xiàng)目{ public partial class denglu : Form {  public denglu()  {   InitializeComponent();  }  model db = new model(); //實(shí)例化數(shù)據(jù)庫對(duì)象   private void button1_Click(object sender, EventArgs e)  {   string strConn = "Data Source=.;Initial Catalog=shopInfo;Integrated Security=True"; //連接數(shù)據(jù)庫   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()) //輸入密碼等于數(shù)據(jù)庫密碼登錄成功且彈出音樂框    {     MessageBox.Show( "登錄成功!");     userName.Text = "";     passWord.Text = "";     caozuoyemain frm = new caozuoyemain();     frm.ShowDialog();    }    else    {     MessageBox.Show("密碼錯(cuò)誤!");  //否則密碼錯(cuò)誤     userName.Text = "";     passWord.Text = "";     }   }   catch (Exception)   {    throw;    //拋出異常   }   finally   {    Connection.Close();  //關(guān)閉數(shù)據(jù)庫   }   }   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.操作界面:

C#收銀系統(tǒng),C#收銀系統(tǒng)設(shè)計(jì),C#超市收銀系統(tǒng)

代碼如下:

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 夢(mèng)之翼小組項(xiàng)目{ public partial class caozuoyemain : Form {  public caozuoyemain()  {   InitializeComponent();  }  public double totalPrice;//每種商品的總價(jià)  public double total; //所有商品的總價(jià)  public double shijijin;//顧客給的錢數(shù)  public double yingzhao;// 找給顧客的錢數(shù)  public string mingcheng;//每件商品的名稱  public double shuliang;//每件商品的數(shù)量  public double jiage;//每件商品的價(jià)格  public int i = 0; //商品收費(fèi)的id   model db = new model(); //實(shí)例化數(shù)據(jù)庫對(duì)象   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; //每一次商品的單個(gè)金額    jiage = Convert.ToDouble(price.Text);   shuliang = Convert.ToDouble(number.Text); //數(shù)據(jù)類型的轉(zhuǎn)換      switch (jisuanfangshi.SelectedIndex)   {    case 0:     totalPrice = jiage * shuliang;           break;    case 1:      totalPrice = jiage * shuliang*0.8;           break;    case 2:     fanli(); //調(diào)用單個(gè)物品的返利方法          break;   }     total = totalPrice + total; //所有商品的總金額    zongjine.Text = total.ToString();//總金額轉(zhuǎn)換數(shù)據(jù)類型,顯示到文本框里面       i++; //每一次的商品id加1,為了調(diào)出所有商品的最后一個(gè)數(shù)據(jù)    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("不好意思,信息有誤,注冊(cè)失敗");   }  }     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.收銀員注冊(cè)界面:

C#收銀系統(tǒng),C#收銀系統(tǒng)設(shè)計(jì),C#超市收銀系統(tǒng)

代碼如下:

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 夢(mèng)之翼小組項(xiàng)目{ public partial class zhuce : Form {  public zhuce()  {   InitializeComponent();  }  public string sexValue; //接收性別的字段  model db = new model(); //實(shí)例化數(shù)據(jù)庫對(duì)象   private bool testuserName(string strUsername) //檢測(cè)用戶名的方法  {   bool strResult;// 判斷結(jié)果的接收   Regex exStrUserName = new Regex(@"^[a-zA-Z][a-zA-Z0-9]{3,8}$");   //正則表達(dá)式的書寫   if (strResult = exStrUserName.Match(strUsername).Success)   {    yonghuming_test.Text = "?";   }   else   {    MessageBox.Show("用戶名由3—6位的字母和數(shù)字組成,必須以字母開頭");    }   return strResult;  }   private bool testPassWord(string strUsername) //檢測(cè)密碼的方法  {   bool strResult;// 判斷結(jié)果的接收   Regex exStrUserName = new Regex(@"^[/w/-~!@#$%^&*()+{}[ /]:]{6,16}");   //正則表達(dá)式的書寫   if (strResult = exStrUserName.Match(strUsername).Success)   {    mima_test.Text = "?";   }   else   {    mima_test.Text = "?";    MessageBox.Show("密碼由6—16位的字母和數(shù)字或符號(hào)組成");    }   return strResult;  }  private bool testName(string strUsername) //檢測(cè)姓名的方法  {   bool strResult;// 判斷結(jié)果的接收   Regex exStrUserName = new Regex(@"^([a-zA-Z0-9/u4e00-/u9fa5/·]{2,3})$");   //正則表達(dá)式的書寫   if (strResult = exStrUserName.Match(strUsername).Success)   {    name_test.Text = "?";   }   else   {    name_test.Text = "?";    MessageBox.Show("請(qǐng)文明用語,輸入合法的中文姓名哦");    }    if (name_text.Text == "小貓" || name_text.Text == "小狗" || name_text.Text == "傻逼")   {    name_test.Text = "?";    MessageBox.Show("請(qǐng)文明用語,輸入合法的中文姓名哦");   }   return strResult;  }   private bool testPhonnumber(string strUsername) //檢測(cè)手機(jī)號(hào)的方法  {   bool strResult;// 判斷結(jié)果的接收   Regex exStrUserName = new Regex(@"^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$");   //正則表達(dá)式的書寫   if (strResult = exStrUserName.Match(strUsername).Success)   {    phonnumber_test.Text = "?";   }   else   {    phonnumber_test.Text = "?";    MessageBox.Show("請(qǐng)輸入正確的手機(jī)號(hào)碼");    }   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) //注冊(cè)的點(diǎn)擊事件  {   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("恭喜你注冊(cè)成功,是否轉(zhuǎn)到登錄界面","注冊(cè)成功對(duì)話框",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("不好意思,信息有誤,注冊(cè)失敗");   }  }   private void username_text_Leave(object sender, EventArgs e) //用戶名文本框的光標(biāo)事件  {   if (username_text.Text == "")   {    MessageBox.Show("用戶名不能為空");   }   else   {    testuserName(username_text.Text);   }  }   private void password_text_Leave(object sender, EventArgs e)//密碼文本框的光標(biāo)事件  {   if (password_text.Text == "")   {    MessageBox.Show("密碼不能為空");   }   else   {    testPassWord(password_text.Text);   }  }   private void name_text_Leave(object sender, EventArgs e)//姓名文本框的光標(biāo)事件  {   if (name_text.Text == "")   {    MessageBox.Show("姓名不能為空");   }   else   {    testName(name_text.Text);   }  }   private void phonnumber_text_Leave(object sender, EventArgs e)//手機(jī)號(hào)文本框的光標(biāo)事件  {   if (phonnumber_text.Text == "")   {    MessageBox.Show("手機(jī)號(hào)不能為空");   }   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)  {   }   }}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。  


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到c#教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临邑县| 芜湖县| 当雄县| 新和县| 镇雄县| 乌海市| 股票| 武夷山市| 河津市| 饶阳县| 南木林县| 公安县| 江华| 乃东县| 瓦房店市| 长宁县| 渭南市| 屯留县| 肇源县| 临沭县| 麻城市| 大竹县| 宁远县| 安阳县| 商丘市| 石首市| 山西省| 高青县| 河北省| 五寨县| 清镇市| 青浦区| 澄江县| 新民市| 五家渠市| 铜陵市| 彩票| 礼泉县| 剑阁县| 扶余县| 兴山县|