📄 frmdisc.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DiscSystemModel;
namespace DiscSystemUI
{
public partial class FrmDisc : Form
{
string type;
DiscInfo disc = null;
public FrmDisc(string _type,DiscInfo _disc)
{
InitializeComponent();
this.type = _type;
this.disc = _disc;
}
//设置下拉框
private void SetCmbInfo()
{
List<DiscType> list = new DiscSystemBLL.DiscTypeManager().GetDiscType();
foreach (DiscType dt in list)
{
cmbDiscType.Items.Add(dt.TypeName);
}
}
//页面加载
private void FrmDisc_Load(object sender, EventArgs e)
{
this.SetCmbInfo();
this.SetFrmType();
}
//设置窗体类型
private void SetFrmType()
{
switch (type)
{
case "添加":
this.Text = type;
break;
case "修改":
this.Text = type;
this.SetInfo();
break;
case "删除":
this.Text = type;
this.SetInfo();
foreach (Control ctr in panelEx1.Controls)
{
if (ctr is TextBox || ctr is ComboBox)
{
ctr.Enabled = false;
}
}
btnClear.Enabled = false;
break;
}
}
//设置窗体信息
private void SetInfo()
{
txtDiscName.Text = disc.DiscName;
txtDiscAuthor.Text = disc.Author;
txtDirector.Text = disc.Director;
txtSimple.Text = disc.SimpleInfo;
cmbDiscType.SelectedItem = disc.DiscTP;
}
//获取窗体信息
private void GetInfo()
{
disc.DiscName = txtDiscName.Text;
disc.Author = txtDiscAuthor.Text;
disc.Director = txtDirector.Text;
disc.SimpleInfo = txtSimple.Text;
disc.DiscTP = cmbDiscType.Text;
}
//清空
private void btnClear_Click(object sender, EventArgs e)
{
foreach (Control ctr in panelEx1.Controls)
{
if (ctr is TextBox)
{
ctr.Text = "";
}
}
}
//取消
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
//确定
private void btnOK_Click(object sender, EventArgs e)
{
switch (type)
{
case "添加":
this.GetInfo();
int checkIn = new DiscSystemBLL.DiscInfoManager().InsertDiscInfo(disc);
if (checkIn == 1)
{
MessageBox.Show("添加成功!!");
}
break;
case "修改":
int checkUp = new DiscSystemBLL.DiscInfoManager().UpdateDiscInfo(disc);
if (checkUp == 1)
{
MessageBox.Show("修改成功!!");
}
break;
case "删除":
int checkDel = new DiscSystemBLL.DiscInfoManager().DeleteDiscInfo(disc.DiscID);
if (checkDel == 1)
{
MessageBox.Show("删除成功!!");
}
break;
}
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -