📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Data;
using System.Data.SqlClient;
using UserData;
namespace LtsClient
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.StatusBar statusBar1;
public System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem db_server;
private System.Windows.Forms.MenuItem db_login;
private System.Windows.Forms.MenuItem db_logoff;
private System.Windows.Forms.MenuItem input;
private System.Windows.Forms.MenuItem search;
private System.Windows.Forms.MenuItem msg_send;
private System.Windows.Forms.MenuItem hireout;
private System.Windows.Forms.MenuItem sell_hire;
private System.Windows.Forms.MenuItem report;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.ToolBarButton toolBarButton_Picture;
private System.Windows.Forms.ToolBarButton toolBarButton_exit;
private System.Windows.Forms.ToolBarButton toolBarButton_hide;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem back_winstate;
private System.Windows.Forms.MenuItem exit_winstate;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.db_server = new System.Windows.Forms.MenuItem();
this.db_login = new System.Windows.Forms.MenuItem();
this.db_logoff = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.input = new System.Windows.Forms.MenuItem();
this.search = new System.Windows.Forms.MenuItem();
this.hireout = new System.Windows.Forms.MenuItem();
this.sell_hire = new System.Windows.Forms.MenuItem();
this.report = new System.Windows.Forms.MenuItem();
this.msg_send = new System.Windows.Forms.MenuItem();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.toolBarButton_Picture = new System.Windows.Forms.ToolBarButton();
this.toolBarButton_exit = new System.Windows.Forms.ToolBarButton();
this.toolBarButton_hide = new System.Windows.Forms.ToolBarButton();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.back_winstate = new System.Windows.Forms.MenuItem();
this.exit_winstate = new System.Windows.Forms.MenuItem();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 323);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Size = new System.Drawing.Size(622, 22);
this.statusBar1.TabIndex = 1;
this.statusBar1.Text = "离线状态,请连接服务器...";
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.db_server,
this.menuItem4,
this.hireout,
this.msg_send,
this.menuItem1});
this.mainMenu1.RightToLeft = System.Windows.Forms.RightToLeft.No;
//
// db_server
//
this.db_server.Index = 0;
this.db_server.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.db_login,
this.db_logoff});
this.db_server.Text = "连接服务器(&L)";
//
// db_login
//
this.db_login.Index = 0;
this.db_login.Text = "连接(&C)";
this.db_login.Click += new System.EventHandler(this.db_login_Click);
//
// db_logoff
//
this.db_logoff.Index = 1;
this.db_logoff.Text = "断开(&E)";
this.db_logoff.Click += new System.EventHandler(this.db_logoff_Click);
//
// menuItem4
//
this.menuItem4.Index = 1;
this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.input,
this.search});
this.menuItem4.Text = "库存(&K)";
//
// input
//
this.input.Index = 0;
this.input.Text = "进货管理(&I)";
this.input.Click += new System.EventHandler(this.input_Click);
//
// search
//
this.search.Index = 1;
this.search.Text = "库存查询(&F)";
this.search.Click += new System.EventHandler(this.search_Click);
//
// hireout
//
this.hireout.Index = 2;
this.hireout.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.sell_hire,
this.report});
this.hireout.Text = "业务管理(&H)";
//
// sell_hire
//
this.sell_hire.Index = 0;
this.sell_hire.Text = "租售管理(&S)";
this.sell_hire.Click += new System.EventHandler(this.sell_hire_Click);
//
// report
//
this.report.Index = 1;
this.report.Text = "账目报表(&R)";
this.report.Click += new System.EventHandler(this.report_Click);
//
// msg_send
//
this.msg_send.Index = 3;
this.msg_send.Text = "信息发送(&M)";
this.msg_send.Click += new System.EventHandler(this.msg_send_Click);
//
// menuItem1
//
this.menuItem1.Index = 4;
this.menuItem1.Text = "测试影碟(&T)";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// toolBar1
//
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton_Picture,
this.toolBarButton_exit,
this.toolBarButton_hide});
this.toolBar1.DropDownArrows = true;
this.toolBar1.ImageList = this.imageList1;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(622, 41);
this.toolBar1.TabIndex = 3;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// toolBarButton_Picture
//
this.toolBarButton_Picture.ImageIndex = 0;
this.toolBarButton_Picture.Text = "背景图";
//
// toolBarButton_exit
//
this.toolBarButton_exit.ImageIndex = 1;
this.toolBarButton_exit.Text = "退出";
//
// toolBarButton_hide
//
this.toolBarButton_hide.ImageIndex = 2;
this.toolBarButton_hide.Text = "最小化";
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// trackBar1
//
this.trackBar1.LargeChange = 10;
this.trackBar1.Location = new System.Drawing.Point(320, -8);
this.trackBar1.Maximum = 100;
this.trackBar1.Minimum = 10;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(134, 45);
this.trackBar1.TabIndex = 5;
this.trackBar1.TickFrequency = 20;
this.trackBar1.Value = 100;
this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
//
// notifyIcon1
//
this.notifyIcon1.ContextMenu = this.contextMenu1;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "销售管理系统";
this.notifyIcon1.Visible = true;
//
// contextMenu1
//
this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.back_winstate,
this.exit_winstate});
//
// back_winstate
//
this.back_winstate.Index = 0;
this.back_winstate.Text = "还原";
this.back_winstate.Click += new System.EventHandler(this.back_winstate_Click);
//
// exit_winstate
//
this.exit_winstate.Index = 1;
this.exit_winstate.Text = "退出";
this.exit_winstate.Click += new System.EventHandler(this.exit_winstate_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(622, 345);
this.Controls.Add(this.trackBar1);
this.Controls.Add(this.toolBar1);
this.Controls.Add(this.statusBar1);
this.ImeMode = System.Windows.Forms.ImeMode.On;
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.Text = "销售管理系统";
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void db_login_Click(object sender, System.EventArgs e)
{
System.Windows.Forms.Form loginFrm=new LtsClient.loginFrm();
loginFrm.MdiParent=this;
loginFrm.Text="登录服务器";
loginFrm.Show();
//连接数据库
}
private void db_logoff_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process[] myProcesses;
myProcesses =System.Diagnostics.Process.GetProcessesByName("LtsClient");
foreach(System.Diagnostics.Process myProcess in myProcesses)
{
myProcess.Kill();
}
Application.Exit();
this.Close();
//退出
}
private void input_Click(object sender, System.EventArgs e)
{
if(FPara.CheckLogin())
{
System.Windows.Forms.Form inputFrm=new LtsClient.inputFrm();
inputFrm.MdiParent=this;
inputFrm.Text="库存输入";
inputFrm.Show();
}
//输入数据
}
private void search_Click(object sender, System.EventArgs e)
{
if(FPara.CheckLogin())
{
System.Windows.Forms.Form searchFrm=new LtsClient.searchFrm();
searchFrm.MdiParent=this;
searchFrm.Text="库存查询";
searchFrm.Show();
}
//查询数据
}
private void sell_hire_Click(object sender, System.EventArgs e)
{
if(FPara.CheckLogin())
{
System.Windows.Forms.Form hireoutFrm=new LtsClient.hireoutFrm();
hireoutFrm.MdiParent=this;
hireoutFrm.Text="业务管理";
hireoutFrm.Show();
}
//业务管理
}
private void report_Click(object sender, System.EventArgs e)
{
if(FPara.CheckLogin())
{
System.Windows.Forms.Form SReportFrm=new LtsClient.SReportFrm();
SReportFrm.MdiParent=this;
SReportFrm.Text="业务报表";
SReportFrm.Show();
}
}
private void msg_send_Click(object sender, System.EventArgs e)
{
if(FPara.CheckLogin())
{
System.Windows.Forms.Form chatFrm=new LtsClient.chatFrm();
chatFrm.MdiParent=this;
chatFrm.Text="业务联系";
chatFrm.Show();
}
}//信息发送
private void menuItem1_Click(object sender, System.EventArgs e)
{
if(FPara.CheckLogin())
{
System.Windows.Forms.Form testFrm=new LtsClient.testFrm();
testFrm.MdiParent=this;
testFrm.Text="测试影碟";
testFrm.Show();
}
}//测试影碟
private Bitmap NowImage;
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch(toolBar1.Buttons.IndexOf(e.Button))
{
case 0: Open_Dialog_Picture(sender,e);
break;
case 1: db_logoff_Click(sender,e);
break;
case 2: hide_Click(sender,e);
break;
}
}//按钮
private void Open_Dialog_Picture(object sender, System.EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Bitmaps|*.bmp|JPEG Images|*.jpg|GIF images|*.gif|PNG Images|*.png";
if (DialogResult.OK == openFileDialog.ShowDialog())
{
if (NowImage != null)
NowImage.Dispose ();
Bitmap tmpBmp= (Bitmap)Image.FromFile (openFileDialog.FileName, true);
bool IsAlpha = Image.IsAlphaPixelFormat (tmpBmp.PixelFormat);
if (IsAlpha == false)
{
NowImage = new Bitmap (tmpBmp.Width, tmpBmp.Height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage (NowImage);
g.DrawImage (tmpBmp, 0,0);
g.Dispose ();
tmpBmp.Dispose ();
}
else
{
NowImage = tmpBmp;
}
this.BackgroundImage=NowImage;
}
}//背景图
private void hide_Click(object sender, System.EventArgs e){
WindowState = FormWindowState.Minimized;
this.Hide();
}//最小化
private void trackBar1_Scroll(object sender, System.EventArgs e)
{
this.Opacity=trackBar1.Value*0.01;
}//透明度
private void exit_winstate_Click(object sender, System.EventArgs e)
{
db_logoff_Click(sender,e);
}//退出
private void back_winstate_Click(object sender, System.EventArgs e)
{
this.Show();
this.Activate();
WindowState = FormWindowState.Normal;
}//还原
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -