⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shouji.cs

📁 这是一个C#开发的手机管理系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace WindowsApplication2
{
    public partial class ShouJi : Form
    {
        public ShouJi()
        {
            InitializeComponent();
        }


        private void button5_Click(object sender, EventArgs e)
        { 
            Thread th = new Thread(new ThreadStart(fun));
            th.Start();
            this.Close();
        }      
        private void fun()
        {
            new Form2().ShowDialog(); 
        }
        private void button2_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into 手机信息表 (手机串号, 入网标志,颜色, 品牌 ,型号,状态,供货商代码)" +
                " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",
                textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, textBox7.Text,textBox8.Text 
                );
            new Database().insert(sql);
            ShonJi_Load(sender, e);
        }

        private void ShonJi_Load(object sender, EventArgs e)
        {
            Database db = new Database();
            DataSet ds = db.query("select * from 手机信息表", "per");
            this.dataGridView1.DataSource = ds.Tables["per"];

            DataColumnCollection dcc = ds.Tables["per"].Columns;//获得列的集合
            foreach (DataColumn var in dcc)
            {
                string lieming = var.ColumnName;//获得列名
                comboBox1.Items.Add(lieming);
                comboBox1.SelectedIndex = 0;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sql = string.Format("select  * from 手机信息表 where {0} like '%{1}%' ",
                comboBox1.Text, textBox1.Text);
            DataSet ds = new Database().query(sql, "por");
            dataGridView1.DataSource = ds.Tables["por"];
        }

        private void dataGridView1_Click(object sender, EventArgs e)
        {
            dataGridView1.CurrentRow.Selected = true;
            int index = dataGridView1.CurrentRow.Index;
            textBox2.Text = dataGridView1[0, index].Value.ToString();
            textBox3.Text = dataGridView1[1, index].Value.ToString();
            textBox4.Text = dataGridView1[2, index].Value.ToString();
            textBox5.Text = dataGridView1[3, index].Value.ToString();
            textBox6.Text = dataGridView1[4, index].Value.ToString();
            textBox7.Text = dataGridView1[5, index].Value.ToString();
            textBox8.Text = dataGridView1[6, index].Value.ToString();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            int index = dataGridView1.CurrentRow.Index;
            string sql = string.Format("delete from 手机信息表 where 手机串号='{0}'",
                dataGridView1[0, index].Value.ToString());
            new Database().insert(sql);
            ShonJi_Load(sender, e);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int index = dataGridView1.CurrentRow.Index;
            string sql = string.Format(
                "update 手机信息表 set 手机串号='{0}',入网标志='{1}',颜色='{2}', 品牌='{3}', 型号='{4}', 状态='{5}',供货商代码='{6}'" +
               " where 手机串号='{0}'", textBox2.Text, textBox3.Text, textBox4.Text,
                textBox5.Text, textBox6.Text, textBox7.Text,textBox8.Text,
                dataGridView1[0, index].Value.ToString());
            new Database().insert(sql);
            ShonJi_Load(sender, e);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -