📄 mainform.cs
字号:
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Controls.Add(this.userID);
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.endDate);
this.panel1.Controls.Add(this.startDate);
this.panel1.Controls.Add(this.label8);
this.panel1.Controls.Add(this.year);
this.panel1.Controls.Add(this.month);
this.panel1.Controls.Add(this.label7);
this.panel1.Controls.Add(this.label6);
this.panel1.Controls.Add(this.label5);
this.panel1.Controls.Add(this.label2);
this.panel1.Location = new System.Drawing.Point(0, 48);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(192, 304);
this.panel1.TabIndex = 1;
//
// userID
//
this.userID.Location = new System.Drawing.Point(64, 96);
this.userID.Name = "userID";
this.userID.Size = new System.Drawing.Size(121, 20);
this.userID.TabIndex = 15;
//
// button1
//
this.button1.BackColor = System.Drawing.Color.LightSteelBlue;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Location = new System.Drawing.Point(64, 176);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(120, 23);
this.button1.TabIndex = 14;
this.button1.Text = "查 询 数 据";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// endDate
//
this.endDate.Location = new System.Drawing.Point(64, 144);
this.endDate.Name = "endDate";
this.endDate.Size = new System.Drawing.Size(120, 21);
this.endDate.TabIndex = 13;
//
// startDate
//
this.startDate.Location = new System.Drawing.Point(64, 120);
this.startDate.Name = "startDate";
this.startDate.Size = new System.Drawing.Size(120, 21);
this.startDate.TabIndex = 12;
//
// label8
//
this.label8.Location = new System.Drawing.Point(8, 152);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(56, 16);
this.label8.TabIndex = 8;
this.label8.Text = "结束时间";
//
// year
//
this.year.Items.AddRange(new object[] {
"2006年",
"2007年",
"2008年",
"2009年",
"2010年",
"2011年",
"2012年"});
this.year.Location = new System.Drawing.Point(8, 32);
this.year.Name = "year";
this.year.Size = new System.Drawing.Size(64, 20);
this.year.TabIndex = 7;
//
// month
//
this.month.Items.AddRange(new object[] {
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月"});
this.month.Location = new System.Drawing.Point(80, 32);
this.month.Name = "month";
this.month.Size = new System.Drawing.Size(104, 20);
this.month.TabIndex = 6;
this.month.SelectedIndexChanged += new System.EventHandler(this.month_SelectedIndexChanged);
//
// label7
//
this.label7.BackColor = System.Drawing.SystemColors.ControlLight;
this.label7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label7.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label7.Location = new System.Drawing.Point(-8, 64);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(200, 24);
this.label7.TabIndex = 5;
this.label7.Text = "查 询 数 据";
this.label7.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
//
// label6
//
this.label6.BackColor = System.Drawing.SystemColors.ControlLight;
this.label6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label6.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label6.Location = new System.Drawing.Point(-8, -8);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(200, 32);
this.label6.TabIndex = 4;
this.label6.Text = "月 份 数 据";
this.label6.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 128);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(56, 16);
this.label5.TabIndex = 3;
this.label5.Text = "起始时间";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 104);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 0;
this.label2.Text = "用户名";
//
// dataGrid1
//
this.dataGrid1.AllowSorting = false;
this.dataGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(192, 48);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ParentRowsVisible = false;
this.dataGrid1.Size = new System.Drawing.Size(368, 304);
this.dataGrid1.TabIndex = 2;
this.dataGrid1.Click += new System.EventHandler(this.dataGrid1_Click);
this.dataGrid1.CurrentCellChanged += new System.EventHandler(this.dataGrid1_CurrentCellChanged);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(560, 353);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.panel1);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu1;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "管理主窗口";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 彻底退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
if(this.UID== null){
if(e != null) e.Cancel = true;
Application.Exit();
}
}
private void menuItem7_Click(object sender, System.EventArgs e) {
this.MainForm_Closing(null,null);
}
/// <summary>
/// 登录服务器设置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem8_Click(object sender, System.EventArgs e) {
XFMAS.SetWin sw = new SetWin();
sw.SetCheckBoxState(false);
sw.ShowDialog();
}
/// <summary>
/// 注册IP地址到服务器
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem3_Click(object sender, System.EventArgs e) {
XFMAS.RegisterIP ri = new RegisterIP();
ri.ShowDialog();
}
/// <summary>
/// 设置提醒时间
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem14_Click(object sender, System.EventArgs e) {
SetAlertTime sat = new SetAlertTime();
sat.ShowDialog();
}
/// <summary>
/// 设置用户->IP
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem11_Click(object sender, System.EventArgs e) {
SetUsers su = new SetUsers();
su.ShowDialog();
}
private void menuItem15_Click(object sender, System.EventArgs e) {
AboutUs au = new AboutUs();
au.ShowDialog();
}
/// <summary>
/// 月份改变时载入相关月份的数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void month_SelectedIndexChanged(object sender, System.EventArgs e) {
if(!Public.CheckIsRule("R_001")) return;
try{
this.dataGrid1.TableStyles.Clear();
//取月份
DateTime toDate = new DateTime();
try{
toDate = Convert.ToDateTime(this.year.Text.Replace("年","") + "-" + this.month.Text.Replace("月","") + "-1");
}catch(Exception ex){
MessageBox.Show("月份设置不正确,系统出现异常信息:\r\n" + ex.Message.ToString());
return;
}
this.ds = DBConn.GetResultsByMonth(toDate,this.UID);
this.dataGrid1.DataSource = this.ds.Tables[0];
//去掉空行
((DataTable)this.dataGrid1.DataSource).DefaultView.AllowNew = false;
Public.SizeColumnsToContent(this.dataGrid1,-1,this.ds.Tables[0],null);
this.dataGrid1.CaptionText = this.year.Text + this.month.Text + "份的食堂就餐情况:";
if(this.UID != null){
this.dataGrid1.CaptionText = this.year.Text + this.month.Text + "份"+ this.UID +"("+ DBConn.GetUserRealName(this.UID) +")在食堂的就餐情况:";
}
if(this.userID.Enabled){
DataGridTextBoxColumn dgtb = (DataGridTextBoxColumn)this.dataGrid1.TableStyles[0].GridColumnStyles[0];
dgtb.TextBox.Click += new EventHandler(TextBox_Click_Today);
}
}catch(Exception ex){
MessageBox.Show(ex.Message.ToString());
return;
}
}
/// <summary>
/// 载入今日就餐条目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TextBox_Click_Today(object sender,System.EventArgs e){
System.Windows.Forms.DataGridCell dc = this.dataGrid1.CurrentCell;
string _val = this.ds.Tables[0].Rows[dc.RowNumber][dc.ColumnNumber].ToString();
string _date = _val.Replace("年","-").Replace("月","-").Replace("日","");
DataTable t = DBConn.TodayItem(_date + " 0:00:00",_date + " 23:59:59");
TodayItem ti = new TodayItem();
ti.dataGrid1.DataSource = t;
ti.dataGrid1.CaptionText = _date;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -