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

📄 gonghuo.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 Gonghuo : Form
    {
        public Gonghuo()
        {
            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 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 Gonghuo_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 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 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);
            Gonghuo_Load(sender, e);
        }

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

        private void button3_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);
            Gonghuo_Load(sender, e);
        }
    }
}

⌨️ 快捷键说明

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