📄 workbillform.cs
字号:
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();
DevExpress.XtraEditors.MemoEdit textBox=new DevExpress.XtraEditors.MemoEdit();
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.Properties.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 textBox = new TextBox();
DevExpress.XtraEditors.TextEdit textBox=new DevExpress.XtraEditors.TextEdit();
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.Properties.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,true,panel);
CreateTextBoxControl("处理时间",wBContentInfo.opdate,new Point(piontX+200,piontY),true,panel);
CreateMultTextBoxControl("处理内容",wBContentInfo.opcontent,new Point(piontX,piontY+27),true,panel);
c.Controls.Add(panel);
}
}
#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(){
try{
satisfyList = m_OtherBLL.getAppraiseGrade();
OtherInfo oInfo = new OtherInfo();
oInfo.gmark=0;
oInfo.gshow="";
satisfyList.Add(oInfo);
this.combWBGrade.DataSource = satisfyList;
this.combWBGrade.ValueMember ="gmark";
this.combWBGrade.DisplayMember = "gshow";
}catch(Exception ex){
MessageBox.Show(ex.Message);
}
}
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 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.tbCFax.Text = customerInfo.cfax.Trim().ToString();
//this.tbCEmail.Text = customerInfo.cemail;
//this.tbBZ.Text = customerInfo.ccomment;
}
}
private void DownLoadWBCInfo(WBContentInfo wBContentInfo){
this.tbOpName.Text=wBContentInfo.opname;
this.tbOpContent.Text=wBContentInfo.opcontent;
this.tbOpDate.Text = wBContentInfo.opdate;
}
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;
}
}
#endregion
#region 校验方面
private bool IsNeedSavedOPC(){
if(this.tbOpContent.Text.Trim().Equals("")){
return false;
}
if(this.m_WBContentInfo!=null){
if(this.tbOpContent.Text.Trim().Equals(m_WBContentInfo.opcontent.Trim())){
return false;
}
}
return true;
}
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 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.tbOpContent.Text.Trim().Length>500){
MessageBox.Show("处理内容的长度不能大于500个字符","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return false;
}
return true;
}
#endregion
#region 保存方面
private void SaveOpContent(){
this.isNeedSavedOPC=IsNeedSavedOPC();
if(isNeedSavedOPC){
SaveWBCInfo();
}
}
private void GetWBContent(int wid){
WBContentInfo temp_WBContentInfo=null;
try{
if(wid>-1){
IList list = this.m_WBContentBLL.getWBContentByWBId(wid);
for(int i=list.Count-1;i>-1;i--){
temp_WBContentInfo=(WBContentInfo)list[i];
if(temp_WBContentInfo.opid.Equals(m_opId)){
m_WBContentInfo=temp_WBContentInfo;
DownLoadWBCInfo(temp_WBContentInfo);
}
else{
AutoCreatWBCText(temp_WBContentInfo,this.AutoOpContentPanel);
}
}
}
}catch(Exception ex){
MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
private void SaveWBCInfo(){
if(m_WBContentInfo!=null){
this.tbOpDate.Text=DateTime.Now.ToString();
m_WBContentInfo.opdate=DateTime.Now.ToString();
m_WBContentInfo.opcontent = this.tbOpContent.Text;
m_WBContentBLL.updateWBContent(m_WBContentInfo);
}
else{
m_WBContentInfo=new WBContentInfo();
this.tbOpDate.Text=DateTime.Now.ToString();
m_WBContentInfo.wbid = this.m_wid;
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);
}
}
private void UploadWorkBillInfo(){
int temp_grade=this.combWBGrade.SelectedValue==null ? 0:(int)this.combWBGrade.SelectedValue;
if(this.m_WorkBillInfo!=null){
m_WorkBillInfo.comment=this.tbCComment.Text;
m_WorkBillInfo.brief = this.tbWBBrief.Text;
if(this.combWBState.SelectedValue is int){
m_WorkBillInfo.state = (int)this.combWBState.SelectedValue;
m_WorkBillInfo.statename = (string)this.combWBState.Text;
}
if(temp_grade!=0){
m_WorkBillInfo.grade=temp_grade;
}
//m_WorkBillInfo.ndate=DateTime.Now.ToString();
}
}
private void SaveWorkBill(){
this.isNeedSavedWBC=IsNeedSavedWBInfo();
if(isNeedSavedWBC){
UploadWorkBillInfo();
this.m_WorkBillBLL.updateWorkBill(m_WorkBillInfo);
}
}
//整个页面的保存
private void Save(){
try{
bool canSave = ValidateData();
if(canSave){
SaveOpContent();
SaveWorkBill();
if(this.isNeedSavedOPC ||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(this.m_CustomerInfo!=null)
{
this.isNeedSavedOPC = this.IsNeedSavedOPC();
this.isNeedSavedWBC = this.IsNeedSavedWBInfo();
if(isNeedSavedOPC || 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();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -