?? workbillspnform.cs
字號:
private void CreateCombBoxControl(string labelName,int valueIndex,Point point,bool enabled,Panel panel){
IList list=null;
try{
list = m_OtherBLL.getAppraiseGrade();
OtherInfo oInfo = new OtherInfo();
oInfo.gmark=0;
oInfo.gshow="";
list.Add(oInfo);
ComboBox comboBox = new ComboBox();
comboBox.Location= new System.Drawing.Point(point.X+72, point.Y);
if(list!=null && list.Count>0){
comboBox.Size = new Size(112, 21);
comboBox.DataSource = list;
comboBox.ValueMember="gmark";
comboBox.DisplayMember = "gshow";
}
panel.Controls.Add(comboBox);
comboBox.SelectedValue = valueIndex;
CreateLabelControl(labelName,point,panel);
}catch(Exception ex){
MessageBox.Show(ex.Message);
}
}
//多行文本
private void CreateMultTextBoxControl(string labelName,string textValue,Point point,Panel panel) {
CreateMultTextBoxControl(labelName,textValue,point,true,panel);
}
private void CreateMultTextBoxControl(string labelName,string textValue,Point point,bool enabled,Panel panel) {
TextBox textBox = new TextBox();
textBox.Location= new System.Drawing.Point(point.X+72, point.Y);
textBox.Size = new Size(312, 40);
textBox.Multiline=true;
textBox.Text = textValue;
textBox.BorderStyle = BorderStyle.FixedSingle;
textBox.ReadOnly = enabled;
textBox.TabStop = enabled;
textBox.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(189)), ((System.Byte)(219)), ((System.Byte)(255)));
panel.Controls.Add(textBox);
CreateLabelControl(labelName,point,panel);
//return panel;
}
//單行文本
private void CreateTextBoxControl(string labelName,string textValue,Point point,Panel panel) {
CreateTextBoxControl(labelName,textValue,point,true,panel);
}
private void CreateTextBoxControl(string labelName,string textValue,Point point,bool enabled,Panel panel) {
textBox.Location= new System.Drawing.Point(point.X+72, point.Y);
textBox.Size = new Size(112, 21);
textBox.Text = textValue;
textBox.BorderStyle = BorderStyle.FixedSingle;
textBox.ReadOnly = enabled;
textBox.TabStop = enabled;
textBox.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(189)), ((System.Byte)(219)), ((System.Byte)(255)));
panel.Controls.Add(textBox);
CreateLabelControl(labelName,point,panel);
}
private void AutoCreatWBCText(WBContentInfo wBContentInfo,Control c){
if(wBContentInfo!=null){
Panel panel=new Panel();
panel.Size=new Size(400, 88);
panel.Dock = DockStyle.Top;
int piontX=13;
int piontY=0;
Point point = new Point(piontX,piontY);
CreateTextBoxControl("操 作 員",wBContentInfo.opname,point,false,panel);
CreateTextBoxControl("處理時間",wBContentInfo.opdate,new Point(piontX+200,piontY),false,panel);
CreateMultTextBoxControl("處理內容",wBContentInfo.opcontent,new Point(piontX,piontY+27),false,panel);
c.Controls.Add(panel);
}
//return panel;
}
private void InstallCmbItem(ComboBox cmbBox){
try{
if(cmbBox!=null){
IList list = m_OtherBLL.getAppraiseGrade();
OtherInfo oInfo = new OtherInfo();
oInfo.gmark=0;
oInfo.gshow="";
list.Add(oInfo);
cmbBox.DataSource = list;
cmbBox.ValueMember ="gmark";
cmbBox.DisplayMember = "gshow";
}
}catch(Exception ex){
MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
#endregion
#region 初始化方面
private void RoleLimit()
{
SysoperatorInfo sysinfo=new SysoperatorInfo();
sysinfo=ShareClass.sysinfo;
if(sysinfo.olevel!="系統管理員")
{
//滿意度
this.combWBGrade.Enabled = false;
//用戶評議
this.tbCComment.Enabled = false;
}
}
//初始化工單滿意度下拉列表
private void InitializeCmbWBState(){
InstallCmbItem(combWBGrade);
}
//初始化服務商的滿意度下拉列表
private void InitializeCmbSPNState(){
InstallCmbItem(cmbSPGrade);
}
//初始化工單狀態
private void InitializeCombCState(){
IList list = this.m_OtherBLL.getWBState();
if(list.Count>0){
OtherInfo oInfo = new OtherInfo();
this.combWBState.DataSource = list;
this.combWBState.ValueMember = "wbsid";
this.combWBState.DisplayMember="wbstate";
}
}
//初始化服務商服務記錄信息
private void InitializeSPNInfo(){
IList list = this.m_SPNBLL.getSPServiceNoteByWBId(this.m_wid);
if(list.Count>0){
m_SPNInfo = (SPServiceNoteInfo)list[0];
}
DownLoadSPNInfo(m_SPNInfo);
}
private void DownLoadSPNInfo(SPServiceNoteInfo spnInfo){
this.tbSPName.Text = spnInfo.sname;
this.cmbSPGrade.SelectedValue = spnInfo.grade;
this.tbSPDate.Text = spnInfo.sdate;
this.tbSPComment.Text = spnInfo.comment;
this.tbSPContent.Text = spnInfo.scontent;
this.tbSPDate.Text = spnInfo.sdate;
}
private void DownLoadCustomerInfo(CustomerInfo customerInfo){
if(customerInfo!=null){
this.tbCName.Text = customerInfo.cname;
this.tbCtype.Text = customerInfo.ctname;
this.tbTelNo.Text = customerInfo.ctelnumber;
this.tbCcontact.Text = customerInfo.ccontact;
this.tbCsex.Text = customerInfo.csex;
this.tbCAddress.Text = customerInfo.caddress;
//this.tbOpName.Text = this.m_opName;
//this.tbCFax.Text = customerInfo.cfax.Trim().ToString();
//this.tbCEmail.Text = customerInfo.cemail;
//this.tbBZ.Text = customerInfo.ccomment;
}
}
private void DownLoadWorkBillInfo(WorkBillInfo workBillInfo){
if(workBillInfo!=null){
this.tbTelNo.Text = workBillInfo.ctelnumber;
this.tbCallingTime.Text = workBillInfo.ndate;
this.tbCComment.Text=workBillInfo.comment;
this.tbWBBrief.Text=workBillInfo.brief;
this.combWBState.SelectedValue = workBillInfo.state;
this.combWBGrade.SelectedValue = workBillInfo.grade;
//this.combWBState.Text=workBillInfo.statename ;
}
}
#endregion
#region 校驗方面
private bool IsNeedSavedWBInfo(){
if(m_WorkBillInfo!=null){
if(this.combWBState.SelectedValue is int){
if(this.m_WorkBillInfo.state!=(int)this.combWBState.SelectedValue){
return true;
}
}
if(!this.m_WorkBillInfo.brief.Trim().Equals(this.tbWBBrief.Text.Trim())){
return true;
}
if(!this.m_WorkBillInfo.comment.Trim().Equals(this.tbCComment.Text.Trim())){
return true;
}
if(this.combWBGrade.SelectedValue is int){
if(this.m_WorkBillInfo.grade!=(int)this.combWBGrade.SelectedValue){
return true;
}
}
}
return false;
}
private bool IsNeedSavedSPNInfo(){
if(this.m_SPNInfo!=null){
if(!m_SPNInfo.sname.Trim().Equals(this.tbSPName.Text.Trim())){
return true;
}
if(!this.m_SPNInfo.scontent.Trim().Equals(this.tbSPContent.Text.Trim())){
return true;
}
if(!this.m_SPNInfo.comment.Trim().Equals(this.tbSPComment.Text.Trim())){
return true;
}
if(this.cmbSPGrade.SelectedValue is int){
if(this.m_SPNInfo.grade!=(int)this.cmbSPGrade.SelectedValue){
return true;
}
}
}
return false;
}
private bool ValidateData(){
if(this.m_CustomerInfo==null)
{
MessageBox.Show("沒有客戶信息","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return false;
}
if(this.tbWBBrief.Text.Trim().Length>50){
MessageBox.Show("工單簡介的長度不能大于50個字符","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return false;
}
if(this.tbCComment.Text.Trim().Length>500){
MessageBox.Show("用戶評議的的長度不能大于500個字符","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return false;
}
if(this.tbSPContent.Text.Trim().Length>500){
MessageBox.Show("服務內容的長度不能大于500個字符","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return false;
}
if(this.tbSPComment.Text.Trim().Length>500){
MessageBox.Show("服務商的用戶評議長度不能大于500個字符","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return false;
}
return true;
}
#endregion
#region 保存方面
//上傳工單信息
private void UploadWorkBillInfo(WorkBillInfo workBillInfo){
int temp_grade=(this.combWBGrade.SelectedValue is int)?(int)this.combWBGrade.SelectedValue:0;
if(workBillInfo!=null){
workBillInfo.comment=this.tbCComment.Text;
workBillInfo.brief = this.tbWBBrief.Text;
if(this.combWBState.SelectedValue is int){
workBillInfo.state = (int)this.combWBState.SelectedValue;
workBillInfo.statename = (string)this.combWBState.Text;
}
if(temp_grade!=0){
workBillInfo.grade=temp_grade;
}
}
}
//上傳服務商記錄信息
private void UploadSPNInfo(SPServiceNoteInfo spnInfo){
if(spnInfo!=null){
spnInfo.comment = this.tbSPComment.Text;
spnInfo.scontent = this.tbSPContent.Text;
spnInfo.grade = (this.cmbSPGrade.SelectedValue is int)?(int)this.cmbSPGrade.SelectedValue:0;
}
}
//工單保存
private void SaveWorkBill(){
this.isNeedSavedWBC=IsNeedSavedWBInfo();
if(isNeedSavedWBC && m_WorkBillInfo!=null){
UploadWorkBillInfo(m_WorkBillInfo);
this.m_WorkBillBLL.updateWorkBill(m_WorkBillInfo);
}
}
//服務商記錄
private void SaveSPNInfo(){
this.isNeedSavedSPN = IsNeedSavedSPNInfo();
if(isNeedSavedSPN && m_SPNInfo!=null){
UploadSPNInfo(m_SPNInfo);
m_SPNBLL.updateSPServiceNote(m_SPNInfo);
//更新服務商表里的滿意度為0時表示沒有選滿意度,不保存
if(m_SPNInfo.grade!=0){
m_SPBLL.changeServiceProviderGrade(m_SPNInfo.sid,m_SPNInfo.grade);
}
}
}
//整個頁面的保存
private void Save(){
try{
bool canSave = ValidateData();
if(canSave){
SaveWorkBill();
SaveSPNInfo();
if(this.isNeedSavedSPN ||this.isNeedSavedWBC){
MessageBox.Show("保存成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.DialogResult = DialogResult.Yes;
}
else{
MessageBox.Show("您沒有修改不需要保存!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
}catch(Exception ex){
MessageBox.Show("保存失敗"+ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
#endregion
#endregion
#region events
private void btnClose_Click(object sender, System.EventArgs e) {
if(m_CustomerInfo!=null)
{
this.isNeedSavedSPN = this.IsNeedSavedSPNInfo();
this.isNeedSavedWBC = this.IsNeedSavedWBInfo();
if(isNeedSavedSPN || isNeedSavedWBC)
{
DialogResult dlg = MessageBox.Show("您有修改但還沒有保存,是否保存!","詢問",MessageBoxButtons.YesNo,MessageBoxIcon.Asterisk);
if(dlg==DialogResult.Yes)
{
this.Save();
}
}
}
this.DialogResult = DialogResult.Cancel;
}
//保存
private void button1_Click(object sender, System.EventArgs e) {
Save();
}
private void WorkBillSPNForm_Load(object sender, System.EventArgs e) {
combWBGrade.TabIndex = 20;
}
#endregion
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -