?? wbcreatucontrol.cs
字號:
this.btnRefreshWBL.Location = new System.Drawing.Point(216, 320);
this.btnRefreshWBL.Name = "btnRefreshWBL";
this.btnRefreshWBL.TabIndex = 1;
this.btnRefreshWBL.Text = "刷新";
this.btnRefreshWBL.Click += new System.EventHandler(this.btnRefreshWBL_Click);
//
// btnCreatWB
//
this.btnCreatWB.Location = new System.Drawing.Point(88, 320);
this.btnCreatWB.Name = "btnCreatWB";
this.btnCreatWB.TabIndex = 0;
this.btnCreatWB.Text = "生成工單";
this.btnCreatWB.Click += new System.EventHandler(this.btnCreatWB_Click);
//
// tabP_WBList
//
this.tabP_WBList.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(131)), ((System.Byte)(194)), ((System.Byte)(231)));
this.tabP_WBList.Controls.Add(this.panelControl2);
this.tabP_WBList.Controls.Add(this.panel_TWBList);
this.tabP_WBList.Font = new System.Drawing.Font("宋體", 9F);
this.tabP_WBList.Location = new System.Drawing.Point(0, 0);
this.tabP_WBList.Name = "tabP_WBList";
this.tabP_WBList.Selected = false;
this.tabP_WBList.Size = new System.Drawing.Size(872, 415);
this.tabP_WBList.TabIndex = 1;
this.tabP_WBList.Title = "當天工單列表";
//
// panelControl2
//
this.panelControl2.Controls.Add(this.simpleButton2);
this.panelControl2.Controls.Add(this.btnRefreshTWBL);
this.panelControl2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelControl2.Location = new System.Drawing.Point(513, 0);
this.panelControl2.Name = "panelControl2";
this.panelControl2.Size = new System.Drawing.Size(359, 415);
this.panelControl2.TabIndex = 2;
this.panelControl2.Text = "panelControl2";
//
// btnRefreshTWBL
//
this.btnRefreshTWBL.Location = new System.Drawing.Point(216, 136);
this.btnRefreshTWBL.Name = "btnRefreshTWBL";
this.btnRefreshTWBL.TabIndex = 0;
this.btnRefreshTWBL.Text = "刷新";
this.btnRefreshTWBL.Click += new System.EventHandler(this.btnRefreshTWBL_Click);
//
// simpleButton2
//
this.simpleButton2.Location = new System.Drawing.Point(216, 200);
this.simpleButton2.Name = "simpleButton2";
this.simpleButton2.TabIndex = 1;
this.simpleButton2.Text = "編輯";
this.simpleButton2.Click += new System.EventHandler(this.btnEdit_Click);
//
// WBCreatUControl
//
this.AutoScroll = true;
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(131)), ((System.Byte)(194)), ((System.Byte)(231)));
this.Controls.Add(this.tabControl2);
this.Name = "WBCreatUControl";
this.Size = new System.Drawing.Size(872, 440);
((System.ComponentModel.ISupportInitialize)(this.panel_WBList)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.panel_TWBList)).EndInit();
this.tabP_CreatWB.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.tbOpContent.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tbTelNo.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tbCallTime.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
this.panelControl1.ResumeLayout(false);
this.tabP_WBList.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.panelControl2)).EndInit();
this.panelControl2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#region method
private ListViewHelper m_TWBListView=null;
private void InitializeCmbOPState(){
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.BackColor=Color.FromArgb(ShareClass.Rcolor,ShareClass.Gcolor,ShareClass.Bcolor);
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.BackColor=Color.FromArgb(ShareClass.Rcolor,ShareClass.Gcolor,ShareClass.Bcolor);
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 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){
MessageBox.Show(ex.Message);
return false;
}
}
private void addOPContent(int wbid)
{
m_WBContentInfo=new WBContentInfo();
m_WBContentInfo.wbid = wbid;
m_WBContentInfo.opid=this.m_opId;
m_WBContentInfo.opname=this.m_opName;
m_WBContentInfo.opdate=DateTime.Now.ToString();
m_WBContentInfo.opcontent = this.tbOpContent.Text;
m_WBContentBLL.addWBContent(m_WBContentInfo);
}
/// <summary>
/// 生成工單
/// </summary>
private void CreatWorkBill(CustomerInfo customerInfo){
try{
if(customerInfo!=null && canSaved){
WorkBillInfo wbi = UploadWorkBill(customerInfo);
if(wbi!=null){
int wbid=m_WorkBillBLL.addWorkBill(wbi);
addOPContent(wbid);
RefreshWBList(customerInfo.id);
this.isNeddRefreshTWBLV = true;
MessageBox.Show("工單生成成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
//canSaved
}catch(Exception ex){
MessageBox.Show(ex.Message);
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){
try
{
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);
CustomerInfo customerInfo =(CustomerInfo)m_CustomerBLL.getCustomerById(workBillInfo.cid);
if(spnList.Count>0)
{
this.m_dlg = new WorkBillSPNForm(customerInfo,workBillInfo).ShowDialog();
}
else
{
this.m_dlg = new WorkBillForm(customerInfo,workBillInfo).ShowDialog();
}
}
}
}
catch(Exception ex)
{
Console.Write(ex.Message);
}
}
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.Visible=ev.canSave;
this.isNeddRefreshTWBLV = true;
}
private void btnCreatWB_Click(object sender, System.EventArgs e) {
CreatWorkBill(this.m_CustomerInfo);
}
private void tabControl2_SelectionChanged(object sender, System.EventArgs e) {
if(tabControl2.SelectedIndex==1 && isNeddRefreshTWBLV){
this.RefreshTodayWBList();
isNeddRefreshTWBLV = false;
}
else if(tabControl2.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);
}
}
//刷新操作員當天列表
private void btnRefreshTWBL_Click(object sender, System.EventArgs e) {
this.RefreshTodayWBList();
this.isNeddRefreshWBLV = true;
}
//刷新用戶工單列表
private void btnRefreshWBL_Click(object sender, System.EventArgs e) {
if(TelCallingControl.CurrentCustomerInfo!=null){
this.m_CustomerInfo = TelCallingControl.CurrentCustomerInfo;
RefreshWBList(TelCallingControl.CurrentCustomerInfo.id);
isNeddRefreshWBLV = false;
}
}
#endregion
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -