📄 mainform.cs
字号:
//文件名:MainForm.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MyCommunity
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private string MyBgPhoto;
private string MyAddress;
private string MyTel;
private string MyCode;
private string MyWeb;
private string MySlogan;
private string MyBgPhotoShow;
private string MyOperator = "";
private string MyCommunity;
private string MyIcon;
private void MainForm_Load(object sender, EventArgs e)
{
try
{
//添加ThreadException事件关联程序
Application.ThreadException += MyThreadException;
//从小区信息数据表中读取基本信息
this.GetCommunityInformation();
//显示登录对话框
LoginForm MyDlg = new LoginForm();
MyDlg.Text = "欢迎使用" + MySlogan;
MyDlg.ShowDialog(this);
this.MyOperator = MyDlg.用户名称TextBox.Text;
//根据用户的操作权限配置系统菜单
SetUserOperateMenu();
//最大化显示系统主窗体
if (MyOperator.Length > 0)
{
this.WindowState = FormWindowState.Maximized;
}
//设置系统背景图像信息
this.BackgroundImage = new Bitmap(this.MyBgPhotoShow, true);
this.Icon = new Icon(this.MyIcon);
//设置系统标题栏显示文字
this.Text = MySlogan;
}
catch
{
this.Close();
}
}
public void MyThreadException(Object sender, System.Threading.ThreadExceptionEventArgs e)
{//系统异常处理代码
string MyInfo = "错误名称:" + e.Exception.Source + ",错误信息:" + e.Exception.Message;
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
protected override void WndProc(ref Message SystemMessage)
{//实现在系统关闭前给予用户提示
switch (SystemMessage.Msg)
{
case 0x0112:
if (((int)SystemMessage.WParam) == 61536)
{
退出系统ToolStripMenuItem_Click(null, null);
}
else
{
base.WndProc(ref SystemMessage);
}
break;
default:
base.WndProc(ref SystemMessage);
break;
}
}
public void GetCommunityInformation()
{//从小区信息数据表中读取基本信息
//从app.config文件中读取数据库连接字符串信息
String MySQLConnectionString = global::MyCommunity.Properties.Settings.Default.DBCommunityConnectionString;
string MySQL = "Select * From 小区信息 Where 优先级=1";
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
DataTable MyTable = new DataTable();
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyAdapter.Fill(MyTable);
MyBgPhoto = Application.StartupPath + "\\Data\\" + (String)MyTable.Rows[0]["背景图像"];
MyAddress = (String)MyTable.Rows[0]["小区地址"];
MyTel = (String)MyTable.Rows[0]["服务电话"];
MyCode = (String)MyTable.Rows[0]["邮政编码"];
MyWeb = (String)MyTable.Rows[0]["小区网站"];
MySlogan = (String)MyTable.Rows[0]["系统名称"];
MyCommunity = (String)MyTable.Rows[0]["小区名称"];
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
MyBgPhotoShow = Application.StartupPath + "\\Data\\Show" + (String)MyTable.Rows[0]["背景图像"];
MyIcon = Application.StartupPath + "\\Data\\" + (String)MyTable.Rows[0]["标志图标"];
}
//根据用户的操作权限配置系统菜单
public void SetUserOperateMenu()
{
String MySQLConnectionString = global::MyCommunity.Properties.Settings.Default.DBCommunityConnectionString;
string MySQL = "Select * From 操作用户 Where 用户名称='" + this.MyOperator + "'";
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
DataTable MyTable = new DataTable();
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyAdapter.Fill(MyTable);
if ((int)MyTable.Rows[0]["基本管理之业主登记管理"] == 0)
{
this.业主登记管理ToolStripMenuItem.Visible = false;
this.业主登记管理ToolStripSeparator.Visible = false;
this.业主登记管理ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["基本管理之业主迁出管理"] == 0)
{
this.业主迁出管理ToolStripMenuItem.Visible = false;
this.业主迁出管理ToolStripSeparator.Visible = false;
this.业主迁出管理ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["基本管理之楼栋信息管理"] == 0)
{
this.楼栋信息管理ToolStripMenuItem.Visible = false;
this.楼栋信息管理ToolStripSeparator.Visible = false;
this.楼栋信息管理ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["基本管理之公共财产管理"] == 0)
{
this.公共财产管理ToolStripMenuItem.Visible = false;
this.公共财产管理ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["物业管理之服务投诉管理"] == 0)
{
this.服务投诉管理ToolStripMenuItem.Visible = false;
this.服务投诉管理ToolStripSeparator.Visible = false;
this.服务投诉管理ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["物业管理之业主维修管理"] == 0)
{
this.业主维修管理ToolStripMenuItem.Visible = false;
this.业主维修管理ToolStripSeparator.Visible = false;
this.业主维修管理ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["物业管理之公共维修管理"] == 0)
{
this.公共维修管理ToolStripMenuItem.Visible = false;
this.公共维修管理ToolStripSeparator.Visible = false;
this.公共维修管理ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["物业管理之车位使用管理"] == 0)
{
this.车位使用管理ToolStripMenuItem.Visible = false;
this.车位使用管理ToolStripSeparator.Visible = false;
this.车位使用管理ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["物业管理之突发事件管理"] == 0)
{
this.突发事件管理ToolStripMenuItem.Visible = false;
this.突发事件管理ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["费用管理之水电气费登记"] == 0)
{
this.水电气费登记ToolStripMenuItem.Visible = false;
this.水电气费登记ToolStripSeparator.Visible = false;
this.水电气费登记ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["费用管理之水电气费查询"] == 0)
{
this.水电气费查询ToolStripMenuItem.Visible = false;
this.水电气费查询ToolStripSeparator.Visible = false;
this.水电气费查询ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["费用管理之水电气费交纳"] == 0)
{
this.水电气费交纳ToolStripMenuItem.Visible = false;
this.水电气费交纳ToolStripSeparator.Visible = false;
this.水电气费交纳ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["费用管理之物管费用登记"] == 0)
{
this.物管费用登记ToolStripMenuItem.Visible = false;
this.物管费用登记ToolStripSeparator.Visible = false;
this.物管费用登记ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["费用管理之物管费用查询"] == 0)
{
this.物管费用查询ToolStripMenuItem.Visible = false;
this.物管费用查询ToolStripSeparator.Visible = false;
this.物管费用查询ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["费用管理之物管费用交纳"] == 0)
{
this.物管费用交纳ToolStripMenuItem.Visible = false;
this.物管费用交纳ToolStripSeparator.Visible = false;
this.物管费用交纳ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["费用管理之其他费用交纳"] == 0)
{
this.其他费用交纳ToolStripMenuItem.Visible = false;
this.其他费用交纳ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["报表管理之业主统计报表"] == 0)
{
this.业主统计报表ToolStripMenuItem.Visible = false;
this.业主统计报表ToolStripSeparator.Visible = false;
this.业主统计报表ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["报表管理之投诉统计报表"] == 0)
{
this.投诉统计报表ToolStripMenuItem.Visible = false;
this.投诉统计报表ToolStripSeparator.Visible = false;
this.投诉统计报表ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["报表管理之业主维修报表"] == 0)
{
this.业主维修报表ToolStripMenuItem.Visible = false;
this.业主维修报表ToolStripSeparator.Visible = false;
this.业主维修报表ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["报表管理之公共维修报表"] == 0)
{
this.公共维修报表ToolStripMenuItem.Visible = false;
this.公共维修报表ToolStripSeparator.Visible = false;
this.公共维修报表ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["报表管理之收入统计报表"] == 0)
{
this.收入统计报表ToolStripMenuItem.Visible = false;
this.收入统计报表ToolStripButton.Visible = false;
}
if ((int)MyTable.Rows[0]["系统管理之分配用户权限"] == 0)
{
this.分配用户权限ToolStripMenuItem.Visible = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -