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

📄 xiaoshou.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 XiaoShou : Form
    {
        public XiaoShou()
        {
            InitializeComponent();
        }

        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 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 button4_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);
            XiaoShou_Load(sender, e);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            
            int index = dataGridView1.CurrentRow.Index;
            //if (index != null)
            //{
                string sql = string.Format("delete from 销售信息表 where 销售单号='{0}'",
                    dataGridView1[0, index].Value.ToString());
                new Database().insert(sql);
                XiaoShou_Load(sender, e);
            //}
            //else {
            //    MessageBox.Show("请选择一行");
            //}
        }

        private void XiaoShou_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 XiaoShou_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 button7_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);
            XiaoShou_Load(sender, e);
        }

        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();
        }
     

    }
}

⌨️ 快捷键说明

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