📄 wbcreatucontrol.cs
字号:
this.tabControl2.Location = new System.Drawing.Point(0, 0);
this.tabControl2.Name = "tabControl2";
this.tabControl2.SelectedIndex = 0;
this.tabControl2.Size = new System.Drawing.Size(872, 440);
this.tabControl2.TabIndex = 1;
//
// btnRefreshTWBL
//
this.btnRefreshTWBL.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnRefreshTWBL.Location = new System.Drawing.Point(688, 160);
this.btnRefreshTWBL.Name = "btnRefreshTWBL";
this.btnRefreshTWBL.Size = new System.Drawing.Size(75, 24);
this.btnRefreshTWBL.TabIndex = 1;
this.btnRefreshTWBL.Text = "刷新";
this.btnRefreshTWBL.Click += new System.EventHandler(this.btnRefreshTWBL_Click);
//
// btnRefreshWBL
//
this.btnRefreshWBL.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnRefreshWBL.Location = new System.Drawing.Point(216, 288);
this.btnRefreshWBL.Name = "btnRefreshWBL";
this.btnRefreshWBL.Size = new System.Drawing.Size(75, 24);
this.btnRefreshWBL.TabIndex = 11;
this.btnRefreshWBL.Text = "刷新";
this.btnRefreshWBL.Click += new System.EventHandler(this.btnRefreshWBL_Click);
//
// WBCreatUControl
//
this.AutoScroll = true;
this.BackColor = System.Drawing.SystemColors.Menu;
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.tabControl2);
this.Name = "WBCreatUControl";
this.Size = new System.Drawing.Size(872, 440);
this.tabControl1.ResumeLayout(false);
this.tabPCreatWB.ResumeLayout(false);
this.tabPWBList.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#region method
private ListViewHelper m_TWBListView=null;
private void InitializeCmbOPState(){
// this.cmbOPType.Items.Add("处理中");
// this.cmbOPType.Items.Add("已处理");
// this.cmbOPType.Items.Add("已办结");
// this.cmbOPType.Items.Add("已归档");
IList list = this.m_OtherBLL.getWBState();
if(list.Count>0){
OtherInfo oInfo = new OtherInfo();
this.cmbOPType.DataSource = list;
this.cmbOPType.ValueMember = "wbsid";
this.cmbOPType.DisplayMember="wbstate";
}
}
//初始化工单列表
private void InitializeWBType(){
IList list = this.m_OtherBLL.getWBType();
OtherInfo oInfo = new OtherInfo();
oInfo.wbtid=0;
oInfo.wbtype="";
list.Add(oInfo);
this.cmbTCType.DataSource = list;
this.cmbTCType.ValueMember = "wbtid";
this.cmbTCType.DisplayMember="wbtype";
this.cmbTCType.SelectedValue=0;
}
private void InitTodayWBListView(){
m_TWBListView =new ListViewHelper();
m_TWBListView.Dock=DockStyle.Fill;
WorkBillInfoColumn workBillColName = new WorkBillInfoColumn();
m_TWBListView.InitLV_UserDefined(workBillColName,TWBLV_DisplayCol);
m_TWBListView.DoubleClick+=new EventHandler(m_TWBListView_DoubleClick);
this.panel_TWBList.Controls.Add(m_TWBListView);
}
private void InitializeListView(){
m_WBListView =new ListViewHelper();
m_WBListView.Dock=DockStyle.Fill;
WorkBillInfoColumn workBillColName = new WorkBillInfoColumn();
m_WBListView.InitLV_UserDefined(workBillColName,WBLV_DisplayCol);
m_WBListView.DoubleClick+=new EventHandler(m_WBListView_DoubleClick);
this.panel_WBList.Controls.Add(m_WBListView);
}
private IList m_WBList;
private IList m_TWBList;
private void RefreshTodayWBList(){
try{
// if(m_TWBList.Count>0){
// m_TWBList.Clear();
// }
WorkBillInfo workBillInf = new WorkBillInfo();
string dateTime = DateTime.Now.ToString("yyyy-MM-dd");
workBillInf.qadate = dateTime;
workBillInf.qbdate = dateTime;
workBillInf.sid = ShareClass.Operator;
m_TWBList = m_WorkBillBLL.queryWorkBill(workBillInf);
m_TWBListView.Refresh_UserDefine(m_TWBList,workBillInf,WBLV_DisplayCol);
}catch(Exception ex){
Console.Write(ex.Message);
}
}
private bool RefreshWBList(int customerId){
try{
// if(m_WBList.Count>0){
// m_WBList.Clear();
// }
m_WBList = m_WorkBillBLL.getWorkBillByCid(customerId);
m_WBListView.Refresh_UserDefine(m_WBList,new WorkBillInfo(),TWBLV_DisplayCol);
return true;
}catch(Exception ex){
return false;
}
}
/// <summary>
/// 生成工单
/// </summary>
private void CreatWorkBill(CustomerInfo customerInfo){
try{
if(customerInfo!=null && canSaved){
WorkBillInfo wbi = UploadWorkBill(customerInfo);
if(wbi!=null){
m_WorkBillBLL.addWorkBill(wbi);
RefreshWBList(customerInfo.id);
this.isNeddRefreshTWBLV = true;
MessageBox.Show("工单生成成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
//canSaved
}catch(Exception ex){
MessageBox.Show("工单生成失败","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
private WorkBillInfo UploadWorkBill(CustomerInfo customerInfo){
m_workBillInf =new WorkBillInfo();
if(customerInfo!=null){
m_workBillInf.cid = customerInfo.id;
m_workBillInf.cname = customerInfo.cname;
m_workBillInf.ctelnumber = customerInfo.ctelnumber;
m_workBillInf.ndate = this.tbTelNo.Text;
m_workBillInf.sid = ShareClass.Operator;
m_workBillInf.sname = ShareClass.Operator;
m_workBillInf.brief = this.cmbTCType.Text;
if(this.cmbOPType.SelectedValue is int){
m_workBillInf.state=(int)this.cmbOPType.SelectedValue;
m_workBillInf.statename = (string)this.cmbOPType.SelectedText;
}
}
return m_workBillInf;
}
private void DownloadWorkBill(CustomerInfo customerInfo){
//处理类型
this.cmbTCType.SelectedValue = 1;
//来电类型
this.cmbOPType.SelectedIndex=0;
if(customerInfo!=null){
this.tbCallTime.Text = DateTime.Now.ToString("yyyy-MM-dd");
this.tbTelNo.Text = customerInfo.ctelnumber;
}
else{
this.tbTelNo.Text="";
this.tbCallTime.Text="";
}
}
private void LinkWorkBillForm(ListView listView,IList list){
if(listView.SelectedIndices.Count>0 && list!=null){
int index = listView.SelectedIndices[0];
if(list.Count>=index){
WorkBillInfo workBillInfo = (WorkBillInfo)list[index];
IList spnList = this.m_SPServiceNoteBLL.getSPServiceNoteByWBId(workBillInfo.id);
if(spnList.Count>0){
this.m_dlg = new WorkBillSPNForm(this.m_CustomerInfo,workBillInfo).ShowDialog();
}
else{
this.m_dlg = new WorkBillForm(this.m_CustomerInfo,workBillInfo).ShowDialog();
}
}
}
}
private bool ValidateCanSave(){
if(!this.tbTelNo.Text.Trim().Equals("")){
return true;
}
return false;
}
#endregion
#region Events
private void tcc_CustomerInfoChanged(object sender, CustomerInfoChangedEventArgs ev) {
m_CustomerInfo = ev.customerInfo;
DownloadWorkBill(m_CustomerInfo);
canSaved = ValidateCanSave();
RefreshWBList(m_CustomerInfo.id);
this.btnCreatWB.Enabled=ev.canSave;
this.isNeddRefreshTWBLV = true;
}
private void btnCreatWB_Click(object sender, System.EventArgs e) {
CreatWorkBill(this.m_CustomerInfo);
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) {
if(tabControl1.SelectedIndex==1 && isNeddRefreshTWBLV){
this.RefreshTodayWBList();
isNeddRefreshTWBLV = false;
}
else if(tabControl1.SelectedIndex==0 && isNeddRefreshWBLV){
if(m_CustomerInfo!=null){
RefreshWBList(m_CustomerInfo.id);
isNeddRefreshWBLV = false;
}
}
}
private void m_TWBListView_DoubleClick(object sender, EventArgs e) {
LinkWorkBillForm(this.m_TWBListView,this.m_TWBList);
if(this.m_dlg==DialogResult.Yes){
int currentItemIndex = m_TWBListView.SelectedIndices[0];
this.RefreshTodayWBList();
if(this.m_TWBListView.Items.Count>currentItemIndex){
this.m_TWBListView.Items[0].Selected = false;
this.m_TWBListView.Items[currentItemIndex].Selected = true;
}
this.isNeddRefreshWBLV = true;
}
}
private void m_WBListView_DoubleClick(object sender, EventArgs e) {
LinkWorkBillForm(this.m_WBListView,this.m_WBList);
if(this.m_dlg==DialogResult.Yes){
int currentItemIndex = m_WBListView.SelectedIndices[0];
this.RefreshWBList(m_CustomerInfo.id);
this.m_WBListView.Items[0].Selected = false;
this.m_WBListView.Items[currentItemIndex].Selected = true;
this.isNeddRefreshTWBLV = true;
}
}
private void btnEdit_Click(object sender, System.EventArgs e) {
if(m_TWBListView.Items.Count>0){
m_TWBListView_DoubleClick(sender,e);
}
}
#endregion
private void btnRefreshTWBL_Click(object sender, System.EventArgs e) {
this.RefreshTodayWBList();
this.isNeddRefreshWBLV = true;
}
private void btnRefreshWBL_Click(object sender, System.EventArgs e) {
if(m_CustomerInfo!=null){
RefreshWBList(m_CustomerInfo.id);
isNeddRefreshWBLV = false;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -