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

📄 frmmagazineinfoview.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 Bussiness;


namespace UI
{
    public partial class frmMagazineInfoView : Form
    {
        //初始化frmBorrowInfo的实例
        frmBorrowInfo objfrmBorrowInfo = null;
        //初始化业务层SelectInfo类的实例
        SelectInfo objSelectInfo = new SelectInfo();
        public frmMagazineInfoView(frmBorrowInfo from)
        {
            objfrmBorrowInfo = from;
            InitializeComponent();
        }
        //加载窗体时GridMagazineInfo显示期刊表的所有数据
        private void frmMagazineView_Load(object sender, EventArgs e)
        {
            GridMagazineInfo.DataSource = objSelectInfo.SelectMagazineInfo();
        }
        //为lstBookInfo添加图书信息列
        private void AddMagazine()
        {
            DataTable objMagazine = new DataTable();
            objMagazine.Columns.Add("MagazineID",typeof(string));
            objMagazine.Columns.Add("MagazineName",typeof(string));
            objMagazine.Columns.Add("MagazinePrice", typeof(string));
            objMagazine.Columns.Add("MagazineborrowPrice",typeof(string));
            objMagazine.Columns.Add("MagazineEnterTime", typeof(string));
            objMagazine.Columns.Add("MagazineExistent", typeof(string));
            objfrmBorrowInfo.lvItemMagazineID.SubItems.Add(GridMagazineInfo.CurrentRow.Cells[0].Value.ToString());
            objfrmBorrowInfo.lvItemMagazineName.SubItems.Add(GridMagazineInfo.CurrentRow.Cells[1].Value.ToString());
            objfrmBorrowInfo.lvItemMagazinePrice.SubItems.Add(GridMagazineInfo.CurrentRow.Cells[7].Value.ToString());
            objfrmBorrowInfo.lvItemMagazineshelfName.SubItems.Add(GridMagazineInfo.CurrentRow.Cells[8].Value.ToString());
            objfrmBorrowInfo.lvItemMagazineStorageData.SubItems.Add(GridMagazineInfo.CurrentRow.Cells[11].Value.ToString());
            objfrmBorrowInfo.lvItemMagazineLivingNum.SubItems.Add(GridMagazineInfo.CurrentRow.Cells[9].Value.ToString());
            DataRow objMagazineRows = objMagazine.NewRow();
            objMagazineRows["MagazineID"] = GridMagazineInfo.CurrentRow.Cells[0].Value.ToString();
            objMagazineRows["MagazineName"] = GridMagazineInfo.CurrentRow.Cells[1].Value.ToString();
            objMagazineRows["MagazinePrice"] = GridMagazineInfo.CurrentRow.Cells[7].Value.ToString();
            objMagazineRows["MagazineborrowPrice"] = GridMagazineInfo.CurrentRow.Cells[8].Value.ToString();
            objMagazineRows["MagazineEnterTime"] = GridMagazineInfo.CurrentRow.Cells[11].Value.ToString();
            objMagazineRows["MagazineExistent"] = GridMagazineInfo.CurrentRow.Cells[9].Value.ToString();
            objMagazine.Rows.Add(objMagazineRows);
            objfrmBorrowInfo.MagazineDataTable = objMagazine;
            this.Close();
        }
        /// <summary>
        /// 此方法判断当前已经激活哪个选项卡,然后把数据添加到lstBookInfo上
        /// </summary>
        private void SelectdataGridViewToString()
        {
            try
            {
                if (objfrmBorrowInfo.tabControl1.SelectedTab.Text == "出借资料")
                {
                    objfrmBorrowInfo.lstBookInfo.Items.Clear();//清空lstBookInfo的所有内容
                    objfrmBorrowInfo.AddLsitViewMagazineA();//添加lstBookInfo上的属性列
                    objfrmBorrowInfo.txtBookID.Text = GridMagazineInfo.CurrentRow.Cells[0].Value.ToString();
                    AddMagazine();//添加lstBookInfo上的信息列
                }
                else if (objfrmBorrowInfo.tabControl1.SelectedTab.Text == "归还资料")
                {
                    objfrmBorrowInfo.lstBookInfoR.Items.Clear();//清空lstBookInfo的所有内容
                    objfrmBorrowInfo.AddLsitViewMagazineB();//添加lstBookInfo上的属性列
                    objfrmBorrowInfo.txtBookIDR.Text = GridMagazineInfo.CurrentRow.Cells[0].Value.ToString();
                    AddMagazine();//添加lstBookInfo上的信息列
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 双机表中的任意一行数据后就把这行数据返回到lstBookInfo中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GridMagazineInfo_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            SelectdataGridViewToString();
        }
        /// <summary>
        /// 此事件可以根据期刊名称进行模糊查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtMagazineName_TextChanged(object sender, EventArgs e)
        {
            try
      
            {
                if (txtMagazineName.Text.Trim() == string.Empty)
                {
                    GridMagazineInfo.DataSource = null;
                    GridMagazineInfo.DataSource = objSelectInfo.SelectMagazineInfo();
                }
                else
                {
                    GridMagazineInfo.DataSource = null;
                    GridMagazineInfo.DataSource = objSelectInfo.SeleLikeMagazineName(txtMagazineName.Text.Trim());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 此事件可以根据期刊编号进行模糊查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtMagazineID_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (txtMagazineID.Text.Trim() == string.Empty)
                {
                    GridMagazineInfo.DataSource = null;
                    GridMagazineInfo.DataSource = objSelectInfo.SelectMagazineInfo();
                }
                else
                {
                    GridMagazineInfo.DataSource = null;
                    GridMagazineInfo.DataSource = objSelectInfo.SeleLikeMagazineID(txtMagazineID.Text.Trim());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //选择按钮事件
        private void butOK_Click(object sender, EventArgs e)
        {
            SelectdataGridViewToString();
        }
        //关闭当前窗体
        private void butEsc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

⌨️ 快捷键说明

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