C\#슈퍼마켓 수금 시스템 디자인

12576 단어 C#수신 시스템
본 논문 의 사례 는 여러분 에 게 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)
  {
 
  }
  
 }
}


이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기