商品打折管理信息系统 使用C#开发,使用软件是visual studio 2017

页面做的比较简单。
下图左边程序主界面,右边是各个页面的代码。
这里写图片描述
主程序入口代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sale
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
           Application.Run(new Login());
           // Application.Run(new MainForm());//测试用
        }
    }
}

下面是主页面代码。

using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace sale
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
          InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)//修改
        {
           Change form = new Change();
            form.Show();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)//添加
        {
            Add form = new Add();//新建一个对象,打开添加窗口
            form.Show();
        }

        private void button4_Click(object sender, EventArgs e)//删除 不会写直接删除,只好和其他一样,多做一个窗口
        {
            Delete form = new Delete();//打开删除的页面
            form.Show();
        }

        private void button5_Click(object sender, EventArgs e)//查询
        {

               if (this.textBox1.Text.Trim() == "")
            {
                MessageBox.Show("请输入要查询的商品名称", "提示");
            }
                else{
                string str = @"Data Source=zky\sqlexpress;Initial Catalog=sale;Integrated Security=True";
                SqlConnection conn = new SqlConnection(str);
                conn.Open();
                SqlCommand cmd = new SqlCommand();//绑定SqlConnection对象
                cmd.CommandText = "Select* from good where name_good='" + this.textBox1.Text.Trim() + "'";//
                cmd.Connection = conn;
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();//数据集
                sda.Fill(ds);
                this.dataGridView1.DataSource = ds;
                this.dataGridView1.DataMember = ds.Tables[0].ToString();//依次赋值
                this.dataGridView1.AutoGenerateColumns =true;
                dataGridView1.ReadOnly = true;//不允许直接在列表上编辑
                dataGridView1.Columns[2].Visible = false;//第2列不出现在表中
                dataGridView1.Columns[4].Visible = false;//第4列不出现在表中
                dataGridView1.Columns[5].Visible = false;//第5列不出现在表中
                conn.Close();    
            }

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)//主显示框
        {

        }

        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        
  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值