笔记:
详情已经在前面的章节有列述了,这里只点出几个比较重要的:
string name = DataGridView对象.SelectedRows[0].Cells[0].Value.ToString();获取在DataGridView控件中选中的一行的第cells[0]列数据。
窗体样式:
代码如下:
主窗体,“手机销售管理系统”代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace product6._10
{
public partial class FrmSalesManage : Form
{
public FrmSalesManage()
{
InitializeComponent();
}
private void 客户添加ToolStripMenuItem_Click(object sender, EventArgs e)
{
//客户添加
FrmAddClient frmAdd = new FrmAddClient();
frmAdd.MdiParent = this;
frmAdd.Show();
}
private void 客户查询ToolStripMenuItem_Click(object sender, EventArgs e)
{
//查询客户
FrmSelectClient frmSelect = new FrmSelectClient();
frmSelect.MdiParent = this;
frmSelect.Show();
}
private void 客户查询ToolStripMenuItem1_Click(object sender, EventArgs e)
{
//查询客户
FrmSelectClient frmSelect = new FrmSelectClient();
frmSelect.MdiParent = this;
frmSelect.Show();
}
private void 客户添加ToolStripMenuItem1_Click(object sender, EventArgs e)
{
//客户添加
FrmAddClient frmAdd = new FrmAddClient();
frmAdd.MdiParent = this;
frmAdd.Show();
}
//退出所有程序
private void FrmSalesManage_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
private void 安全退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void 安全退出ToolStripMenuItem1_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
查询窗体:“客户查询”代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace product6._10
{
public partial class FrmSelectClient : Form
{
public FrmSelectClient()
{
InitializeComponent();
}
//刷新列表
public void RefreshList()
{
string sql = "select * from Customer";
DataTable table = DBHelper.GetDataTable(sql);
ClientInformation.DataSource = table;
}
//初始换程序选项
private void FrmSelectClient_Load(object sender, EventArgs e)
{
RefreshList();
cbType.Items.Clear();
cbType.Items.A