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

📄 gategoryform.cs

📁 一个超市管理系统,没有错误,非常好,里面什么都有!很使用,很有用
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

//引入命名空间
using DaFanRongMIS.Model.CateGory;
using System.Data.SqlClient;

namespace DaFanRongMIS.ViewController.CateGory
{
    public partial class CateGoryForm : Form
    {
        public CateGoryForm()
        {
            InitializeComponent();
        }

        private void Main_Load(object sender, EventArgs e)
        {
            Show();
        }
        private void Show()
        {
            DataTable dt = CateGoryDao.SelectCateGory();
            if (dt != null)
            {
                listView1.Items.Clear();
                foreach(DataRow dr in dt.Rows)
                {
                    ListViewItem item = new ListViewItem(dr["ID"].ToString());
                    item.SubItems.Add(dr["Name"].ToString());
                    item.SubItems.Add(dr["Memo"].ToString());
                    listView1.Items.Add(item);

                }
            }

        }
         private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                txtID.Text=listView1.SelectedItems[0].SubItems[0].Text;
                txtName.Text = listView1.SelectedItems[0].SubItems[1].Text;
                txtMemo.Text = listView1.SelectedItems[0].SubItems[2].Text;

            }            
           
        }
        CateGoryEntity CateGoryEntity = new CateGoryEntity();
        CateGoryDAOImpl CateGoryDao = new CateGoryDAOImpl();
        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {

           CateGoryEntity.Name = txtName.Text.Trim();
           CateGoryEntity.Memo = txtMemo.Text.Trim();
           string str="";
           if (radTypeMaterial.Checked)
           {
               str = CateGoryDao.AddCateGory(CateGoryEntity, CateGoryDAOImpl.MaterialOrProduct.Material);
           }

           else
           {
               str = CateGoryDao.AddCateGory(CateGoryEntity, CateGoryDAOImpl.MaterialOrProduct.Product);
           }
            if (str == "OK")
            {
                Show();
            }
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
           
            CateGoryEntity.ID = txtID.Text.Trim();
            CateGoryEntity.Name = txtName.Text.Trim();
            CateGoryEntity.Memo = txtMemo.Text.Trim();
          
            string str = CateGoryDao.UpdateCateGory(CateGoryEntity);
            if (str == "OK")
            {
                Show();
            }
        }

        private void bntDel_Click(object sender, EventArgs e)
        {
            
            CateGoryEntity.ID = txtID.Text.Trim();
            CateGoryEntity.Name = txtName.Text.Trim();
            CateGoryEntity.Memo = txtMemo.Text.Trim();          
            string str = CateGoryDao.DeleteCateGory(CateGoryEntity);
            if (str == "OK")
            {
                Show();
            }
            else if(str=="Sorry")
            {
                MessageBox.Show("该类型已被使用,不能删除");
            }
        }
        
        private void radTypeProduct_CheckedChanged(object sender, EventArgs e)
        {
            
        }
    }
}

⌨️ 快捷键说明

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