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

📄 mdifrm_main.cs

📁 汽车销售管理系统,进销存系统典范,值得初学者多多学习
💻 CS
📖 第 1 页 / 共 4 页
字号:
			this.Name = "MdiFrm_Main";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "汽车销售进存销系统";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Resize += new System.EventHandler(this.MdiFrm_Main_Resize);
			this.Closing += new System.ComponentModel.CancelEventHandler(this.MdiFrm_Main_Closing);
			this.Load += new System.EventHandler(this.MdiFrm_Main_Load);
			this.Closed += new System.EventHandler(this.MdiFrm_Main_Closed);
			this.Activated += new System.EventHandler(this.MdiFrm_Main_Activated);
			((System.ComponentModel.ISupportInitialize)(this.sbplabel)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.tbpUserName_m)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.tbpLabel2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.sbpNowTime_m)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.sbpCompany)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.sbpCompany_m)).EndInit();
			this.pnlLeft.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this._timer)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
		
		[DllImport("user32.dll")]
		public static extern bool FlashWindow(IntPtr hWnd,bool bInvert);
			

		
		private void MdiFrm_Main_Load(object sender, System.EventArgs e)
		{
			try
			{
				bool i=FlashWindow(this.Handle,true);
				//			this.Login(0);
				this.Visible=false;
				//if(this.sbpNowTime_m!=null)
				//	this.sbpNowTime_m.Text=DateTime.Now.ToLocalTime().ToLongDateString();
			
				frmLogin log=new frmLogin();
				if(log.ShowDialog()!=DialogResult.Cancel)
				{
					this.isLogExit=false;
					this.Visible=true;
				}
				else
				{
					this.isLogExit=true;
					this.Close();
				}
				if(UserJob.IndexOf("管理员")==-1)
				{
					this.mnuDataRestore.Enabled=false;
				}
				else
					this.mnuDataRestore.Enabled=true;

			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}

//			if(log!=null)
//				log.Hide();
//			else
//				Application.Exit();
		}



		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			try
			{
				if(e.Button==this.tbnExit_m)
					this.mnuExit.PerformClick();
				else if(e.Button==this.tbnInDep_m)
					this.mnuInDep.PerformClick();
				else if(e.Button==this.tbnPay_m)
					this.mnuBuyPay.PerformClick();
				else if(e.Button==this.tbnSell_m)
					this.mnuSelling.PerformClick();
				else if(e.Button==this.tbnSellMon_m)
					this.mnuSellTake.PerformClick();
				else if(e.Button==this.tbnStock_m)
					this.mnuBook.PerformClick();
				else if(e.Button==this.tbnSelPre)
					this.mnuReady.PerformClick();
			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}

		}
		public static bool islog=false;

		private void mnuExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
		

		private void MdiFrm_Main_Resize(object sender, System.EventArgs e)
		{
			try
			{
				this.Dir.Top=this.pnlLeft.Height/2-this.Dir.Height/2;

			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}
		private bool outer=true;
		private void Dir_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(outer)
				{
					this.pnlLeft.Width=this.Dir.Width;
					this.Dir.Text=">>";
					outer=false;
				}
				else
				{
					this.pnlLeft.Width=203;
					this.Dir.Text="<<";
					outer=true;
				}
				this.Dir.Left=this.pnlLeft.Width-this.Dir.Width;

			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}

		private void MdiFrm_Main_Activated(object sender, System.EventArgs e)
		{
//			if(this.tbpUserName_m.Text=="")
			try
			{
				this.tbpUserName_m.Text=UserName;

			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}

		private void MdiFrm_Main_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			try
			{

				if(this.isLogExit)
				{
					foreach(Form form in this.MdiChildren)
						{
							form.Close();
						}
				}
				else
				if(MessageBox.Show("确实要退出系统?","确认退出",MessageBoxButtons.OKCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2)==DialogResult.Cancel)
					e.Cancel=true;
				else
				{
					foreach(Form form in this.MdiChildren)
					{
						form.Close();
					}
					
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
			
		}

		private void MdiFrm_Main_Closed(object sender, System.EventArgs e)
		{
			try
			{

				Application.Exit();
			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}
		/// <summary>
		/// 重新登陆
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void mnuRLog_Click(object sender, System.EventArgs e)
		{
			try
			{
				this.Visible=false;
				foreach(Form chd in this.MdiChildren)
					chd.Close();
				frmLogin log=new frmLogin();
				if(log.ShowDialog()!=DialogResult.Cancel)
				{
					
					this.isLogExit=false;
					this.Visible=true;
				}
				else
				{
					this.isLogExit=true;
					this.Close();
				}
				if(UserJob.IndexOf("管理员")==-1)
				{
					this.mnuDataRestore.Enabled=false;
				}
				else
					this.mnuDataRestore.Enabled=true;
			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}
		private frmStock carBuy;
		/// <summary>
		/// 菜单弹出采购窗体
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void mnuBook_Click(object sender, System.EventArgs e)
		{
			try
			{

				if(carBuy==null||carBuy.Disposing||carBuy.IsDisposed)
				{
					carBuy=null;
					carBuy=new frmStock(UserID);
					carBuy.MdiParent=this;
				}
				carBuy.Show();
				carBuy.Activate();
			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}

		private frmInDepot inDepot;
		/// <summary>
		/// 弹出入库窗体
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void mnuInDep_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(inDepot==null||inDepot.Disposing||inDepot.IsDisposed)
				{
					inDepot=null;
					inDepot=new frmInDepot(UserID);
					inDepot.MdiParent=this;
				}
					inDepot.Show();
					inDepot.Activate();

			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}
		/// <summary>
		/// 库存信息
		/// </summary>
		private frmKunCun cun;
		private void mnuDepCar_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(cun==null||cun.Disposing||cun.IsDisposed)
				{
					cun=null;
					cun=new frmKunCun();
					cun.MdiParent=this;
				}
				cun.Show();
				cun.Activate();
			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}
		/// <summary>
		/// 仓库信息
		/// </summary>
		private	CarStorehouse.frmStorageInfo store;
		private void mnuDepInfo_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(store==null||store.Disposing||store.IsDisposed)
				{
					store=null;
					store=new frmStorageInfo(0,UserID);
					store.MdiParent=this;
				}
				store.Show();
				store.Activate();
			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
			
		}
		/// <summary>
		/// 移库操作
		/// </summary>
		private CarStorehouse.frmShift shift;
		private void mnuMoveCar_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(shift==null||shift.Disposing||shift.IsDisposed)
				{
					shift=null;
					shift=new frmShift(UserID);
					shift.MdiParent=this;
				}
				shift.Show();
				shift.Activate();
			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
			
		}
		/// <summary>
		/// 系统初始化
		/// </summary>
		private frmInitial ini;
		private void mnuSysIni_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(ini==null||ini.Disposing||ini.IsDisposed)
				{
					ini=null;
					ini=new frmInitial(UserID);
					ini.MdiParent=this;
				}
				ini.Show();
				ini.Activate();

			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}
		/// <summary>
		/// 更改密码
		/// </summary>
		private frmRePwd repwd;
		private void mnuPwd_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(repwd==null||repwd.Disposing||repwd.IsDisposed)
				{
					repwd=null;
					repwd=new frmRePwd(UserID,UserName);
					repwd.MdiParent=this;
				}
				repwd.Show();
				repwd.Activate();

			}
			catch(Exception ex)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+ex.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}

		/*预售管理*/
		private SALE.frmPreSaleManager fpsm;
		private void mnuReady_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(UserJob.Equals("预售员") || UserJob.Equals("管理员") || UserJob.Equals("预售经理"))
				{
					
				}
				else
				{
					MessageBox.Show("您没有此权限的操作","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);

⌨️ 快捷键说明

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