⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workbillspnform.cs

📁 汽车销售公司ERP进销存系统 汽车销售公司ERP进销存系统
💻 CS
📖 第 1 页 / 共 3 页
字号:
		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 textBox = new TextBox();
			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 + -