📄 frmsystemconfig.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Data;
namespace GzglClient.Froms
{
/// <summary>
/// frmSystemConfig 的摘要说明。
/// </summary>
public class frmSystemConfig : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox cbArea;
private System.Windows.Forms.Label label2;
private PinkieControls.ButtonXP btnCancel;
private PinkieControls.ButtonXP btnYes;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmSystemConfig()
{
//
// 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.cbArea = new System.Windows.Forms.ComboBox();
this.btnYes = new PinkieControls.ButtonXP();
this.btnCancel = new PinkieControls.ButtonXP();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(48, 56);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 16);
this.label1.TabIndex = 0;
this.label1.Text = "区划选择:";
this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// cbArea
//
this.cbArea.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbArea.Items.AddRange(new object[] {
"连云港市",
"新浦区",
"海州区",
"连云区",
"开发区",
"东海县",
"赣榆县",
"灌云县",
"灌南县"});
this.cbArea.Location = new System.Drawing.Point(128, 48);
this.cbArea.Name = "cbArea";
this.cbArea.Size = new System.Drawing.Size(144, 20);
this.cbArea.TabIndex = 7;
//
// btnYes
//
this.btnYes.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(236)), ((System.Byte)(233)), ((System.Byte)(216)));
this.btnYes.DefaultScheme = true;
this.btnYes.DialogResult = System.Windows.Forms.DialogResult.None;
this.btnYes.Hint = "";
this.btnYes.Location = new System.Drawing.Point(56, 96);
this.btnYes.Name = "btnYes";
this.btnYes.Scheme = PinkieControls.ButtonXP.Schemes.Blue;
this.btnYes.Size = new System.Drawing.Size(75, 26);
this.btnYes.TabIndex = 8;
this.btnYes.Text = "确定";
this.btnYes.Click += new System.EventHandler(this.btnLogin_Click);
//
// btnCancel
//
this.btnCancel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(236)), ((System.Byte)(233)), ((System.Byte)(216)));
this.btnCancel.DefaultScheme = true;
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Hint = "";
this.btnCancel.Location = new System.Drawing.Point(200, 96);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Scheme = PinkieControls.ButtonXP.Schemes.Blue;
this.btnCancel.Size = new System.Drawing.Size(75, 26);
this.btnCancel.TabIndex = 9;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(51, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(240, 23);
this.label2.TabIndex = 10;
this.label2.Text = "提示:在此界面里选择贵单位所在的区划。";
//
// frmSystemConfig
//
this.AcceptButton = this.btnYes;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(342, 166);
this.Controls.Add(this.label2);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnYes);
this.Controls.Add(this.cbArea);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(350, 200);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(350, 200);
this.Name = "frmSystemConfig";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "设置区划";
this.Load += new System.EventHandler(this.frmSystemConfig_Load);
this.ResumeLayout(false);
}
#endregion
private void btnLogin_Click(object sender, System.EventArgs e)
{
string settingFilePath = Application.StartupPath + "//Config//App.xml";//配置文件路径
if(File.Exists(settingFilePath))//检测配置文件是否存在
{
DataSet ds = new DataSet();
ds.ReadXml(settingFilePath);//加载配置文件
#region
switch(cbArea.Text)
{
case "连云港市":
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzgl";
ds.Tables[0].Rows[3]["SettingValue"] = "320700";
break ;
case "新浦区":
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzglxpq";
ds.Tables[0].Rows[3]["SettingValue"] = "320705";
break ;
case "海州区":
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzglhzq";
ds.Tables[0].Rows[3]["SettingValue"] = "320706";
break ;
case "连云区":
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzgllyq";
ds.Tables[0].Rows[3]["SettingValue"] = "320703";
break ;
case "开发区":
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzglkfq";
ds.Tables[0].Rows[3]["SettingValue"] = "320791";
break ;
case "东海县":
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzgldhx";
ds.Tables[0].Rows[3]["SettingValue"] = "320722";
break ;
case "赣榆县":
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzglgyux";
ds.Tables[0].Rows[3]["SettingValue"] = "320721";
break ;
case "灌云县":
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzglgyunx";
ds.Tables[0].Rows[3]["SettingValue"] = "320723";
break ;
case "灌南县":
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzglgnx";
ds.Tables[0].Rows[3]["SettingValue"] = "320822";
break ;
default:
ds.Tables[0].Rows[0]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[1]["SettingValue"] = "218.92.102.27";
ds.Tables[0].Rows[2]["SettingValue"] = "Gzgl";
ds.Tables[0].Rows[3]["SettingValue"] = "320700";
break ;
}
#endregion
ds.WriteXml(settingFilePath);
MessageBox.Show("设置成功!");
this.Close();
}
else
{
MessageBox.Show("设置失败!");
}
}
private void frmSystemConfig_Load(object sender, System.EventArgs e)
{
string settingFilePath = Application.StartupPath + "//Config//App.xml";//配置文件路径
if(File.Exists(settingFilePath))//检测配置文件是否存在
{
DataSet ds = new DataSet();
ds.ReadXml(settingFilePath);//加载配置文件
string _WAreaId = ds.Tables[0].Rows[0]["SettingValue"].ToString();
if(_WAreaId != "")
{
switch(_WAreaId)
{
case "320700":
cbArea.SelectedIndex = 0;
break ;
case "320705":
cbArea.SelectedIndex = 1;
break ;
case "320706":
cbArea.SelectedIndex = 2;
break ;
case "320703":
cbArea.SelectedIndex = 3;
break ;
case "320791":
cbArea.SelectedIndex = 4;
break ;
case "320722":
cbArea.SelectedIndex = 5;
break ;
case "320721":
cbArea.SelectedIndex = 6;
break ;
case "320723":
cbArea.SelectedIndex = 7;
break ;
case "320822":
cbArea.SelectedIndex = 8;
break ;
default:
cbArea.SelectedIndex = 0;
break ;
}
}
}
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -