tuihuo.cs

来自「这是一个C#开发的手机管理系统」· CS 代码 · 共 83 行

CS
83
字号
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 TuiHuo : Form
    {
        public TuiHuo()
        {
            InitializeComponent();
        }

        private void Tuihou_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 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 button2_Click(object sender, EventArgs e)
        {
            string sql = string.Format("insert into 退货信息表 (退货单号,手机串号,退货日期,工号,退机原因)" +
                           " values('{0}','{1}','{2}',{3},'{4}')",
                           textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text
                           );
            new Database().insert(sql);
            Tuihou_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);
            Tuihou_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();
        }
    }
}

⌨️ 快捷键说明

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