📄 selectcustomerform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using CallCenter.BusinessInterfaces.BaseForms.Models;
using CallCenter.BusinessInterfaces;
using CallCenter.BusinessLayer;
using CallCenter.Modules;
namespace CallCenter.BusinessInterfaces.BaseForms {
/// <summary>
/// SelectCustomerForm 的摘要说明。
/// </summary>
public class SelectCustomerForm : System.Windows.Forms.Form {
private System.Windows.Forms.Button btnEnter;
private System.Windows.Forms.Button btnClose;
private IList m_customerList;
private int[] DisplayCol = {1,2,3,4,5,6,8,9};
//private string customerIds=null;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private CustomerInfo m_customerInfo=null;
public CustomerInfo GetCustomerInfo{
get{
return this.m_customerInfo;
}
}
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public SelectCustomerForm() {
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
InitializeListView();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
public SelectCustomerForm(IList customerList):this(){
m_customerList = customerList;
RefreshListView(customerList);
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing ) {
if( disposing ) {
if(components != null) {
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent() {
this.btnEnter = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// btnEnter
//
this.btnEnter.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnEnter.Location = new System.Drawing.Point(440, 16);
this.btnEnter.Name = "btnEnter";
this.btnEnter.Size = new System.Drawing.Size(75, 24);
this.btnEnter.TabIndex = 0;
this.btnEnter.Text = "确定";
this.btnEnter.Click += new System.EventHandler(this.btnEnter_Click);
//
// btnClose
//
this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnClose.Location = new System.Drawing.Point(576, 16);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 24);
this.btnClose.TabIndex = 1;
this.btnClose.Text = "关闭";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// panel1
//
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(696, 368);
this.panel1.TabIndex = 2;
//
// panel2
//
this.panel2.Controls.Add(this.btnEnter);
this.panel2.Controls.Add(this.btnClose);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 368);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(696, 58);
this.panel2.TabIndex = 3;
//
// SelectCustomerForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(696, 426);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "SelectCustomerForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "选择用户";
this.SizeChanged += new System.EventHandler(this.SelectCustomerForm_SizeChanged);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#region method
private ListViewHelper cListView=null;
private void InitializeListView(){
cListView = new ListViewHelper();
cListView.View = View.Details;
cListView.GridLines = true;
cListView.FullRowSelect = true;
cListView.HideSelection = false;
cListView.Dock=DockStyle.Fill;
CustomerInfoColumn cusInfoCol = new CustomerInfoColumn();
cListView.InitLV_UserDefined(cusInfoCol,DisplayCol);
this.panel1.Controls.Add(cListView);
this.cListView.DoubleClick+=new EventHandler(CustomerListView_DoubleClick);
this.cListView.SelectedIndexChanged+=new EventHandler(CustomerListView_SelectedIndexChanged);
}
private void RefreshListView(IList customerList){
try{
//customerList = new CustomerBLL().getCustomerByIds(customerIds);
cListView.Refresh_UserDefine(customerList,new CustomerInfo(),DisplayCol);
}catch(Exception ex){
MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
private void Enters(){
try{
if(this.cListView.SelectedIndices.Count>0){
int index=this.cListView.SelectedIndices[0];
if(m_customerList.Count>=index){
this.m_customerInfo =(CustomerInfo)m_customerList[index];
this.DialogResult=DialogResult.Yes;
}
}
}catch(Exception ex){
MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
#endregion
#region events
private void CustomerListView_DoubleClick(object sender, EventArgs e) {
Enters();
}
private void CustomerListView_SelectedIndexChanged(object sender, EventArgs e) {
// try{
// if(this.cListView.SelectedIndices.Count>0){
// int index=this.cListView.SelectedIndices[0];
// if(m_customerList.Count>=index){
// this.m_customerInfo =(CustomerInfo)m_customerList[index];
// }
// }
// }catch(Exception ex){
// MessageBox.Show(ex.Message);
// }
}
private void btnEnter_Click(object sender, System.EventArgs e) {
Enters();
}
private void btnClose_Click(object sender, System.EventArgs e) {
this.DialogResult=DialogResult.Cancel;
}
#endregion
private void SelectCustomerForm_SizeChanged(object sender, EventArgs e) {
this.panel1.Height=this.Height-86;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -