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

📄 frmsms.cs

📁 车载GPS?今天这个就是最好的工具
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace GEROSYS
{
	/// <summary>
	/// frmNote 的摘要说明。
	/// </summary>
	public class frmSms : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.ComboBox cmbSend;
		private System.Windows.Forms.CheckedListBox lstReceive;
		private System.Windows.Forms.RichTextBox txtNote;
		private System.Windows.Forms.Button cmdAccept;
		private System.Windows.Forms.Button cmdCancel;
		private System.Windows.Forms.Label label3;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmSms()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.cmbSend = new System.Windows.Forms.ComboBox();
			this.label2 = new System.Windows.Forms.Label();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.lstReceive = new System.Windows.Forms.CheckedListBox();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.txtNote = new System.Windows.Forms.RichTextBox();
			this.cmdAccept = new System.Windows.Forms.Button();
			this.cmdCancel = new System.Windows.Forms.Button();
			this.label3 = new System.Windows.Forms.Label();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(48, 40);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(88, 24);
			this.label1.TabIndex = 0;
			this.label1.Text = "发消息人:";
			// 
			// cmbSend
			// 
			this.cmbSend.Location = new System.Drawing.Point(144, 40);
			this.cmbSend.Name = "cmbSend";
			this.cmbSend.Size = new System.Drawing.Size(104, 20);
			this.cmbSend.TabIndex = 1;
			this.cmbSend.Text = "调度室";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(48, 80);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(96, 16);
			this.label2.TabIndex = 2;
			this.label2.Text = "选择收消息人:";
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Location = new System.Drawing.Point(312, 16);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(248, 344);
			this.groupBox1.TabIndex = 3;
			this.groupBox1.TabStop = false;
			// 
			// lstReceive
			// 
			this.lstReceive.Location = new System.Drawing.Point(48, 104);
			this.lstReceive.Name = "lstReceive";
			this.lstReceive.Size = new System.Drawing.Size(200, 244);
			this.lstReceive.TabIndex = 4;
			// 
			// groupBox2
			// 
			this.groupBox2.Location = new System.Drawing.Point(24, 16);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(264, 344);
			this.groupBox2.TabIndex = 5;
			this.groupBox2.TabStop = false;
			// 
			// txtNote
			// 
			this.txtNote.Location = new System.Drawing.Point(312, 56);
			this.txtNote.Name = "txtNote";
			this.txtNote.Size = new System.Drawing.Size(248, 296);
			this.txtNote.TabIndex = 6;
			this.txtNote.Text = "";
			// 
			// cmdAccept
			// 
			this.cmdAccept.Location = new System.Drawing.Point(584, 24);
			this.cmdAccept.Name = "cmdAccept";
			this.cmdAccept.Size = new System.Drawing.Size(80, 32);
			this.cmdAccept.TabIndex = 7;
			this.cmdAccept.Text = "发送";
			this.cmdAccept.Click += new System.EventHandler(this.cmdAccept_Click);
			// 
			// cmdCancel
			// 
			this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.cmdCancel.Location = new System.Drawing.Point(584, 72);
			this.cmdCancel.Name = "cmdCancel";
			this.cmdCancel.Size = new System.Drawing.Size(80, 32);
			this.cmdCancel.TabIndex = 8;
			this.cmdCancel.Text = "取消";
			this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(72, 16);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(104, 24);
			this.label3.TabIndex = 0;
			this.label3.Text = "输入短消息内容";
			// 
			// frmSms
			// 
			this.AcceptButton = this.cmdAccept;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.cmdCancel;
			this.ClientSize = new System.Drawing.Size(688, 370);
			this.Controls.Add(this.cmdCancel);
			this.Controls.Add(this.cmdAccept);
			this.Controls.Add(this.txtNote);
			this.Controls.Add(this.lstReceive);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.cmbSend);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.groupBox2);
			this.Name = "frmSms";
			this.Text = "短消息功能";
			this.Load += new System.EventHandler(this.frmSms_Load);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		private void getReceiveMessageMan()
		{
			AccessData AppClient=new AccessData ();
			DataTable dtEmp =new DataTable();
			try 
			{
				string strSQL = "SELECT  emp_name,mobilphone  FROM emp ";
				dtEmp=AppClient.SelectSQL(strSQL);
				for (int llCount=0;llCount<dtEmp.Rows.Count;llCount++)

				{
					DataRow drEmp;
					drEmp=dtEmp.Rows[llCount];
					lstReceive.Items.Add(drEmp["emp_name"]);
//                    cmbReceive.Items.Add(drEmp["mobilphone"]);

				}
			} 
			catch(Exception ms)
			{
				MessageBox.Show(ms.Message, "General Error");
			}
            
            
		}


		private void radioButton2_Click(object sender, System.EventArgs e)
		{
//			switch(  )
//			{
//				case 0:
//					bFlag = true;
//					setButtonState (false);
//					opInfo = OperateType.appAddInfo;
//					AddClicked();
//					break;
//				case 2:
//					setButtonState (false);
//					opInfo = OperateType.appEditInfo ;
//					break;}			
		}


		private void cmdAccept_Click(object sender, System.EventArgs e)
		{
			string strSQL;
			int liCount=1;
			string sms;
			this.cmdAccept.Enabled =false;
			DateTime d= DateTime.Now;
			AccessData AppClient=new AccessData ();
			for(int liItem=0;liItem<this.lstReceive.CheckedItems.Count ;liItem++)
			{
					string lsname=getMobileByName(this.lstReceive.CheckedItems[liItem].ToString());
					if (txtNote.Text.Trim().Length>70)
					{
						liCount=txtNote.Text.Trim().Length/70;
				
					}
				for (int liScore=0;liScore<liCount;liScore++)
					{
						if (liScore==liCount-1)
							sms=txtNote.Text.Substring(liScore*70);
						else
							sms=txtNote.Text.Substring(liScore*70,70);

						int ret=WinApi.tecoSMS_send(GlobalPara.ComValue,lsname,sms);

						if (ret!=0)
						{
							MessageBox.Show("短消息发送不成功!");
						}
					}
					
					strSQL="insert into shortmess (note_id,sendman,receiveman,send_date,style,note) values('" +AppClient.GetMakeId("shortmess","note_id") +"','" + this.cmbSend.Text.ToString()+ "','" + this.lstReceive.CheckedItems[liItem].ToString() +"',convert(char(120),'" + d +"',10),'0','" +txtNote.Text.ToString()+"')";
					AppClient.ExecuteSQL(strSQL);
			}

			}


		private void frmSms_Load(object sender, System.EventArgs e)
		{
		    getReceiveMessageMan();
		}
		private string getMobileByName(string name)
		{
			AccessData AppClient=new AccessData ();
			DataTable dtEmp =new DataTable();
			try 
			{
				string strSQL = "SELECT  emp_name,mobilphone  FROM emp where emp_name='"+ name +"'";
				dtEmp=AppClient.SelectSQL(strSQL);
				for (int llCount=0;llCount<dtEmp.Rows.Count;llCount++)
				{
					DataRow drEmp;
					drEmp=dtEmp.Rows[llCount];
					return drEmp["mobilphone"].ToString();
				}
			} 
			catch(Exception ms)
			{
				MessageBox.Show(ms.Message, "General Error");
			}
			return null;
		}

		private void cmdCancel_Click(object sender, System.EventArgs e)
		{
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -