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

📄 frmbillsmanagement.cs

📁 本论文叙述了联机考试系统的现状以及C#语言的概况。重点介绍了联机考试系统的实现过程:包括系统分析、 系统调查、 数据流程分析、功能设计、 数据库设计、 系统物理配置方案、 系统实现、 系统测试和调试。
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.ppdlgBills.Document = this.pDocBills;
			this.ppdlgBills.Enabled = true;
			this.ppdlgBills.Icon = ((System.Drawing.Icon)(resources.GetObject("ppdlgBills.Icon")));
			this.ppdlgBills.Location = new System.Drawing.Point(501, 17);
			this.ppdlgBills.MinimumSize = new System.Drawing.Size(375, 250);
			this.ppdlgBills.Name = "ppdlgBills";
			this.ppdlgBills.TransparencyKey = System.Drawing.Color.Empty;
			this.ppdlgBills.Visible = false;
			// 
			// frmBillsManagement
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(921, 375);
			this.Controls.Add(this.btnPrintPreview);
			this.Controls.Add(this.chkIncludeDate);
			this.Controls.Add(this.cboUsrId);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnPrint);
			this.Controls.Add(this.btnDetails);
			this.Controls.Add(this.dbgBills);
			this.Controls.Add(this.btnSearch);
			this.Controls.Add(this.dtpBillDate);
			this.Controls.Add(this.cboPayMode);
			this.Controls.Add(this.txtBillNo);
			this.Controls.Add(this.lblPayMode);
			this.Controls.Add(this.lblBillDate);
			this.Controls.Add(this.lblUser);
			this.Controls.Add(this.lblBillNo);
			this.Name = "frmBillsManagement";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "帐单管理";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.frmBillsManagement_Closing);
			this.Load += new System.EventHandler(this.frmBillsManagement_Load);
			((System.ComponentModel.ISupportInitialize)(this.dbgBills)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void btnSearch_Click(object sender, System.EventArgs e)
		{
			
			if(this.txtBillNo.Text != "")
			{
				searchvalue[0] = this.txtBillNo.Text;
			}
			else
			{
				searchvalue[0] = "";
			}

			if(this.cboUsrId.Text !="")
			{
				searchvalue[1] = this.cboUsrId.Text;
			}
			else
			{
				searchvalue[1] = "";
			}
			if (this.dtpBillDate.Enabled)
			{
				searchvalue[2] =  this.dtpBillDate.Value.ToShortDateString();
			}
			else
			{ 
				searchvalue[2] = "";
			}
			if(this.cboPayMode.Text !="")
			{
				searchvalue[3] = this.cboPayMode.Text;
			}
			else
			{
				searchvalue[3]="";
			}

			SalesAdminManagement billMgmt = new SalesAdminManagement();

			this.dbgBills.DataSource = billMgmt.FetchBillsDetails(searchvalue);
			
			if(this.dbgBills.VisibleRowCount <=0)
			{ 
				// If No records are fetched clearing the Datagrid and setting 
				// the datasource as null
				this.dbgBills.DataSource = null;
				this.dbgBills.Enabled = false;
				MessageBox.Show("未捕获到任何记录");
				this.btnDetails.Enabled = false;
			}
			else
			{
				this.dbgBills.Enabled = true;
				this.btnPrint.Enabled=true;
				this.btnPrintPreview.Enabled=true; 
			}

		}

		private void frmBillsManagement_Load(object sender, System.EventArgs e)
		{
			this.dbgBills.Enabled = false;
			this.btnDetails.Enabled = false;
			
			DataConnection.commnd.CommandText="select distinct UsrId from Bills";
			OleDbDataReader reader = DataConnection.commnd.ExecuteReader();
			while(reader.Read())
			{
				//Loading the User Id to the ComboBox
				this.cboUsrId.Items.Add(reader.GetString(0));
			}
			reader.Close();

			
			DataConnection.commnd.CommandText="select distinct PaymentMode from Bills";
			reader = DataConnection.commnd.ExecuteReader();
			while(reader.Read())
			{
				//Loading the Payment Mode to the ComboBox
				this.cboPayMode.Items.Add(reader.GetString(0));
			}
		reader.Close();
		}

		private void txtBillNo_Validating(object sender, System.ComponentModel.CancelEventArgs e)
		{
			if(this.txtBillNo.Text!= "")
			{
				if(ValidateBillNo()==false)
				{
					e.Cancel = true;
					this.txtBillNo.Select(0,this.txtBillNo.Text.Length);
				}
			}

		}

		private bool ValidateBillNo()
		{
			bool bStatus = true;
			try
			{
				int temp = int.Parse(this.txtBillNo.Text.Trim());
				errBill.SetError (this.txtBillNo,"");
			}
			catch
			{
				errBill.SetError (this.txtBillNo,"请输入一个数字");
				bStatus = false;
			}
			return bStatus;
		}


		private void btnExit_Click(object sender, System.EventArgs e)
		{
			frmMainMenu.varBillsMgmt = 0;
			this.Close();
		}

		private void btnDetails_Click(object sender, System.EventArgs e)
		{
			frmBillsDetails fBD = new frmBillsDetails(this.dbgValue);
			fBD.MdiParent = this.ParentForm;
			fBD.Show();
		}

		private void dbgBills_Click(object sender, System.EventArgs e)
		{
			this.dbgValue = new string[5];

			this.dbgValue[0] = this.dbgBills[this.dbgBills.CurrentRowIndex,0].ToString();
			this.dbgValue[1] = this.dbgBills[this.dbgBills.CurrentRowIndex,1].ToString();
			this.dbgValue[2] = this.dbgBills[this.dbgBills.CurrentRowIndex,2].ToString();
			this.dbgValue[3] = this.dbgBills[this.dbgBills.CurrentRowIndex,3].ToString();
			this.dbgValue[4] = this.dbgBills[this.dbgBills.CurrentRowIndex,4].ToString();

			this.btnDetails.Enabled = true;
		}

		private void frmBillsManagement_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			frmMainMenu.varBillsMgmt = 0;
		}

		private void txtBillNo_MouseHover(object sender, System.EventArgs e)
		{
			this.tipBillMgmt.SetToolTip(this.txtBillNo,"选择用来搜索的帐单编号...(可选)");	
		}

		private void cboUsrId_MouseHover(object sender, System.EventArgs e)
		{
			this.tipBillMgmt.SetToolTip(this.cboUsrId,"选择用来搜索的用户标识...(可选)");	
		}

		private void dtpBillDate_MouseHover(object sender, System.EventArgs e)
		{
			this.tipBillMgmt.SetToolTip(this.dtpBillDate,"选择用来搜索的帐单日期...(可选)");	
		}

		private void cboPayMode_MouseHover(object sender, System.EventArgs e)
		{
			this.tipBillMgmt.SetToolTip(this.cboPayMode,"选择用来搜索的付款方式...(可选)");	
		}

		private void btnDetails_MouseHover(object sender, System.EventArgs e)
		{
			this.tipBillMgmt.SetToolTip(this.btnDetails,"显示所选帐单的详细信息");	
		}

		private void chkIncludeDate_CheckedChanged(object sender, System.EventArgs e)
		{
			if (this.chkIncludeDate.Checked) 
			{
				this.dtpBillDate.Enabled = true;
			}
			else
			{
				if (this.dtpBillDate.Enabled)
				{
					this.dtpBillDate.Enabled = false; 
				}
			}
		}

		private void pDocBills_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
		{
			try
			{
				Graphics	g = e.Graphics;
				DrawTopLabel(g);
				bool more = dataGridPrinter.DrawDataGrid(g);
				if (more == true)
				{
					e.HasMorePages = true;
					dataGridPrinter.PageNumber++;
				}
			}
			catch(Exception excep)
			{
				MessageBox.Show("打印时发生错误。" +excep.Message.ToString());
			}
		}				
		void DrawTopLabel(Graphics g)
		{
			int TopMargin = pDocBills.DefaultPageSettings.Margins.Top;
			lblHeading.Text ="帐单信息";
			g.FillRectangle(new SolidBrush(lblHeading.BackColor), lblHeading.Location.X, lblHeading.Location.Y + TopMargin, lblHeading.Size.Width+100, lblHeading.Size.Height);
			g.DrawString(lblHeading.Text, lblHeading.Font, new SolidBrush(lblHeading.ForeColor), lblHeading.Location.X + 50, lblHeading.Location.Y + TopMargin, new StringFormat());
		}

		private void btnPrint_Click(object sender, System.EventArgs e)
		{
			try
			{
				DataTable dt=(DataTable)this.dbgBills.DataSource; 			dataGridPrinter = new DataGridPrinter(this.dbgBills, pDocBills,dt);
				dataGridPrinter.PageNumber = 1;
				dataGridPrinter.RowCount = 0;
				if (pdlgBills.ShowDialog() == DialogResult.OK)
				{
					pDocBills.Print();
				}
			}
			catch(Exception excep)
			{
				MessageBox.Show("打印时发生错误。" +excep.Message.ToString());
			}
		}

		private void btnPrintPreview_Click(object sender, System.EventArgs e)
		{
			DataTable dt=(DataTable)this.dbgBills.DataSource; 			dataGridPrinter = new DataGridPrinter(this.dbgBills, pDocBills,dt);
			dataGridPrinter.PageNumber = 1;
			dataGridPrinter.RowCount = 0;
			this.ppdlgBills.ShowDialog();
		}

		}
		}
	

⌨️ 快捷键说明

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