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

📄 frmmain.cs

📁 太阳神短信跟踪服务系统
💻 CS
📖 第 1 页 / 共 4 页
字号:
			this.btnModify.Name = "btnModify";
			this.btnModify.Size = new System.Drawing.Size(80, 24);
			this.btnModify.TabIndex = 5;
			this.btnModify.Text = "修改";
			// 
			// btnNew
			// 
			this.btnNew.Location = new System.Drawing.Point(472, 48);
			this.btnNew.Name = "btnNew";
			this.btnNew.Size = new System.Drawing.Size(80, 24);
			this.btnNew.TabIndex = 4;
			this.btnNew.Text = "新增";
			this.btnNew.Click += new System.EventHandler(this.btnNew_Click);
			// 
			// txbMsgContent
			// 
			this.txbMsgContent.Location = new System.Drawing.Point(96, 56);
			this.txbMsgContent.Multiline = true;
			this.txbMsgContent.Name = "txbMsgContent";
			this.txbMsgContent.Size = new System.Drawing.Size(352, 64);
			this.txbMsgContent.TabIndex = 3;
			this.txbMsgContent.Text = "";
			// 
			// cmbMsgType
			// 
			this.cmbMsgType.Location = new System.Drawing.Point(96, 24);
			this.cmbMsgType.Name = "cmbMsgType";
			this.cmbMsgType.Size = new System.Drawing.Size(176, 20);
			this.cmbMsgType.TabIndex = 2;
			this.cmbMsgType.SelectedIndexChanged += new System.EventHandler(this.cmbMsgType_SelectedIndexChanged);
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(24, 56);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(64, 16);
			this.label6.TabIndex = 1;
			this.label6.Text = "信息内容";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(24, 24);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(72, 24);
			this.label5.TabIndex = 0;
			this.label5.Text = "信息类型";
			// 
			// TG_AppSet
			// 
			this.TG_AppSet.Controls.Add(this.listBox1);
			this.TG_AppSet.Controls.Add(this.button7);
			this.TG_AppSet.Controls.Add(this.button6);
			this.TG_AppSet.Controls.Add(this.lblSockState);
			this.TG_AppSet.Controls.Add(this.button4);
			this.TG_AppSet.Location = new System.Drawing.Point(4, 21);
			this.TG_AppSet.Name = "TG_AppSet";
			this.TG_AppSet.Size = new System.Drawing.Size(568, 151);
			this.TG_AppSet.TabIndex = 4;
			this.TG_AppSet.Text = "应用程序设置";
			// 
			// button7
			// 
			this.button7.Location = new System.Drawing.Point(472, 104);
			this.button7.Name = "button7";
			this.button7.Size = new System.Drawing.Size(80, 32);
			this.button7.TabIndex = 3;
			this.button7.Text = "button7";
			this.button7.Click += new System.EventHandler(this.button7_Click);
			// 
			// button6
			// 
			this.button6.Location = new System.Drawing.Point(472, 56);
			this.button6.Name = "button6";
			this.button6.Size = new System.Drawing.Size(80, 32);
			this.button6.TabIndex = 2;
			this.button6.Text = "button6";
			this.button6.Click += new System.EventHandler(this.button6_Click);
			// 
			// lblSockState
			// 
			this.lblSockState.Location = new System.Drawing.Point(16, 8);
			this.lblSockState.Name = "lblSockState";
			this.lblSockState.Size = new System.Drawing.Size(216, 16);
			this.lblSockState.TabIndex = 1;
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(472, 8);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(80, 32);
			this.button4.TabIndex = 0;
			this.button4.Text = "button4";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// statusBar1
			// 
			this.statusBar1.Location = new System.Drawing.Point(0, 220);
			this.statusBar1.Name = "statusBar1";
			this.statusBar1.Size = new System.Drawing.Size(590, 16);
			this.statusBar1.TabIndex = 2;
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(256, 192);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(80, 24);
			this.button2.TabIndex = 3;
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(400, 192);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(80, 24);
			this.button3.TabIndex = 4;
			this.button3.Text = "隐藏";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// timer1
			// 
			this.timer1.Enabled = true;
			this.timer1.Interval = 5900;
			this.timer1.SynchronizingObject = this;
			this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// listBox1
			// 
			this.listBox1.ItemHeight = 12;
			this.listBox1.Location = new System.Drawing.Point(48, 40);
			this.listBox1.Name = "listBox1";
			this.listBox1.Size = new System.Drawing.Size(120, 16);
			this.listBox1.TabIndex = 4;
			// 
			// frmMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(590, 236);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.statusBar1);
			this.Controls.Add(this.tabControl1);
			this.Controls.Add(this.button1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "frmMain";
			this.Text = "太阳神综合管理器";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmMain_Closing);
			this.Load += new System.EventHandler(this.frmMain_Load);
			this.tabControl1.ResumeLayout(false);
			this.TG_Service.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.TG_MsgSet.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.TG_Database.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.TG_MsgContent.ResumeLayout(false);
			this.TG_AppSet.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmMain());

		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			//ApolloNotifyIcon.Visible
			RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Apollo\\ServicePara",true);

			switch (tabControl1.SelectedIndex)
			{
				case 0:
				{
					if(MessageBox.Show("您确定要修改数据库连接参数吗",Application.ProductName.ToString() + "提示",MessageBoxButtons.YesNo) == DialogResult.No )
					{
						return;
					}

					//if(textBox1.Text.ToString().Trim()=="" && Int32.Parse(textBox1.Text.ToString().Trim())<30000 && Int32.Parse(textBox1.Text.ToString().Trim())>300000)
					//判断各参数和正确性和范围
					//if(textBox1.Text.ToString().Trim()=="")
					if(!Regex.Match(textBox1.Text.Trim(),"^[0-9]{2,3}$").Success)
					{
						MessageBox.Show("运行周期超出范围!",Application.ProductName.ToString() + "提示");
						return;
					}

					if(txtSqlHost.Text.Trim() =="" || txtSqlName.Text.Trim()=="")
					{
						MessageBox.Show("服务器名和数据库用户名不能为空!",Application.ProductName.ToString() + "提示");
						return;
					}

					if(cboDataBase1.Text.Trim() == "" || cboDataBase1.Text.Trim() == ".")
					{
						MessageBox.Show("数据库名不能为空!",Application.ProductName.ToString() + "提示");
						return;
					}
					try
					{
						rk.SetValue("RunningPeriods",textBox1.Text.ToString().Trim());
						string connStr="server=" + txtSqlHost.Text.Trim() + ";uid=" + txtSqlName.Text.Trim() + ";pwd=" + txtSqlPWD.Text.Trim() + ";database=" + cboDataBase1.Text.Trim();
						rk.SetValue("ConnectionString",connStr);
					}
					catch(Exception ex)
					{
						MessageBox.Show("参数写入注册表败,原因" + ex.Message.ToString() ,Application.ProductName.ToString() + "提示");
					}


					break;
				}

				case 1:
				{
					if(MessageBox.Show("您确定要修改发送短信参数吗",Application.ProductName.ToString() + "提示",MessageBoxButtons.YesNo) == DialogResult.No )
					{
						return;
					}
					//判断各参数和正确性和范围

					if(txbJLlogName.Text.Trim()=="" || txbJLlogPWD.Text.Trim()=="")
					{
						MessageBox.Show("巨澜登录用户名和密码不能为空!",Application.ProductName.ToString() + "提示");
						return;
					}

					//将短信参数写回注册表
					try
					{
						rk.SetValue("RunningPeriods",textBox1.Text.Trim());
						rk.SetValue("strJLlogName",txbJLlogName.Text.Trim());
						rk.SetValue("strJLlogPWD",txbJLlogPWD.Text.Trim());

						rk.SetValue("NewAdd",BooleanToInt(chkNewAdd.Checked));
						rk.SetValue("Birthday",BooleanToInt(chkBirthday.Checked));
						rk.SetValue("BottleNeck",BooleanToInt(chkBottleNeck.Checked));
						rk.SetValue("Festival",BooleanToInt(chkFestival.Checked));
						rk.SetValue("HaveCadreman",BooleanToInt(chkHaveCadreman.Checked));
						rk.SetValue("Logistics",BooleanToInt(chkLogistics.Checked));
						rk.SetValue("DawnMarginRemind",BooleanToInt(chkDawnMarginRemind.Checked));
						rk.SetValue("CheckRemind",BooleanToInt(chkCheckRemind.Checked));

					}
					catch(Exception ex)
					{
						throw new Exception("写注册表失败!原因:" + ex.Message);
					}
					break;
				}

				case 2:
				{
					break;
				}
				case 3:
				{
					break;
				}
				case 4:
				{
					break;
				}
			}
			rk.Close();
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			//ApolloNotifyIcon.Visible=false;
		}

		private void menuItem7_Click(object sender, System.EventArgs e)
		{
			ApolloNotifyIcon.Visible=false;
			Application.Exit();
		}

		private void menuItem1_Click(object sender, System.EventArgs e)
		{
			this.Show();
		}

		private void frmMain_Load(object sender, System.EventArgs e)
		{
			//从注册表读取短信参数
			RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Apollo\\ServicePara",true);
			try
			{
				textBox1.Text =(string)rk.GetValue("RunningPeriods");
				string connStr=(string)rk.GetValue("ConnectionString");

				string delimStr = ";";
				char [] delimiter = delimStr.ToCharArray();

				//string connStr="server=xzh; uid=sa; pwd=; database=apollo";
				string []connStrArr = connStr.Split(delimiter,4);
				txtSqlHost.Text = connStrArr[0].Substring(connStrArr[0].LastIndexOf("=")+1,connStrArr[0].Length-(connStrArr[0].Substring(0,connStrArr[0].LastIndexOf("=")).Length+1));
				SqlHost=txtSqlHost.Text.Trim();
				
				txtSqlName.Text = connStrArr[1].Substring(connStrArr[1].LastIndexOf("=")+1,connStrArr[1].Length-(connStrArr[1].Substring(0,connStrArr[1].LastIndexOf("=")).Length+1));
				SqlName = txtSqlName.Text.Trim();

				txtSqlPWD.Text =  connStrArr[2].Substring(connStrArr[2].LastIndexOf("=")+1,connStrArr[2].Length-(connStrArr[2].Substring(0,connStrArr[2].LastIndexOf("=")).Length+1));
				SqlPWD = txtSqlPWD.Text.Trim();

				cboDataBase1.Text= connStrArr[3].Substring(connStrArr[3].LastIndexOf("=")+1,connStrArr[3].Length-(connStrArr[3].Substring(0,connStrArr[3].LastIndexOf("=")).Length+1));
				SqlDataBase = cboDataBase.Text.Trim();
			}

			catch(Exception ex)
			{
				throw new Exception("读注册表失败!原因:" + ex.Message);
			}
			rk.Close();

			//读取ApolloMsgSrv当前状态
			ApolloMsgSrv.Refresh();
			if(ApolloMsgSrv.Status.ToString()=="Running")
			{
				btnSrvOption.Text="停止服务";
			}
			else
			{
				btnSrvOption.Text="开始服务";
			}

			ApolloNotifyIcon.Visible =true;
			this.WindowState=FormWindowState.Minimized;
			this.Hide();
			//this.Show();
			//Common.writeLog(logFilePath,"abcdefg");
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			ApolloNotifyIcon.Visible=true;
			this.Hide();
		}

		private void frmMain_Closing(object sender, CancelEventArgs e)
		{
			e.Cancel = true;
			ApolloNotifyIcon.Visible=true;
			this.Hide();
		}

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			ApolloMsgSrv.Start();
		}

		private void menuItem4_Click(object sender, System.EventArgs e)
		{
			ApolloMsgSrv.Pause();
		}

		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			ApolloMsgSrv.Stop();
		}

		private void button5_Click(object sender, System.EventArgs e)
		{
			folderBrowserDialog1.ShowDialog();
			txbBakPath.Text=folderBrowserDialog1.SelectedPath;
		}

		private void button8_Click(object sender, System.EventArgs e)
		{
			openFileDialog1.ShowDialog();
			txbResPath.Text=openFileDialog1.FileName;
		}


		private void btnBakcup_Click(object sender, System.EventArgs e)
		{
			if(txbBakPath.Text.Trim()=="")
			{
				MessageBox.Show("请输入正确的备份文件名!",Application.ProductName.ToString() + "提示");
				return;
			}

			if(cboDataBase.SelectedIndex ==-1)

⌨️ 快捷键说明

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