📄 frmviewresult.cs
字号:
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// dbgStudent
//
this.dbgStudent.BackgroundColor = System.Drawing.Color.LightSteelBlue;
this.dbgStudent.DataMember = "";
this.dbgStudent.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dbgStudent.Location = new System.Drawing.Point(136, 152);
this.dbgStudent.Name = "dbgStudent";
this.dbgStudent.ReadOnly = true;
this.dbgStudent.Size = new System.Drawing.Size(504, 224);
this.dbgStudent.TabIndex = 6;
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("Century Gothic", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
this.label1.Location = new System.Drawing.Point(160, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(191, 39);
this.label1.TabIndex = 8;
this.label1.Text = "查 看 结 果";
//
// pDoc
//
this.pDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pDoc_PrintPage);
//
// pdlgStudent
//
this.pdlgStudent.Document = this.pDoc;
//
// ppdlgStudent
//
this.ppdlgStudent.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.ppdlgStudent.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.ppdlgStudent.ClientSize = new System.Drawing.Size(400, 300);
this.ppdlgStudent.Document = this.pDoc;
this.ppdlgStudent.Enabled = true;
this.ppdlgStudent.Icon = ((System.Drawing.Icon)(resources.GetObject("ppdlgStudent.Icon")));
this.ppdlgStudent.Location = new System.Drawing.Point(93, 17);
this.ppdlgStudent.MinimumSize = new System.Drawing.Size(375, 250);
this.ppdlgStudent.Name = "ppdlgStudent";
this.ppdlgStudent.TransparencyKey = System.Drawing.Color.Empty;
this.ppdlgStudent.Visible = false;
//
// button1
//
this.button1.BackColor = System.Drawing.Color.Transparent;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.button1.Location = new System.Drawing.Point(312, 392);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 24);
this.button1.TabIndex = 12;
this.button1.Text = "打印预览(&R)";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// frmViewResult
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(653, 483);
this.ControlBox = false;
this.Controls.Add(this.button1);
this.Controls.Add(this.btnSearch);
this.Controls.Add(this.btnHelp);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.lblSubject);
this.Controls.Add(this.lblTo);
this.Controls.Add(this.lblFrom);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnPrint);
this.Controls.Add(this.dtpTo);
this.Controls.Add(this.dtpFrom);
this.Controls.Add(this.cboSubject);
this.Controls.Add(this.dbgStudent);
this.Font = new System.Drawing.Font("Times New Roman", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Location = new System.Drawing.Point(146, 115);
this.Name = "frmViewResult";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Result";
this.TopMost = true;
this.Load += new System.EventHandler(this.frmViewResult_Load);
((System.ComponentModel.ISupportInitialize)(this.dbgStudent)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
// [STAThread]
// static void Main()
// { f=new frmExamResult();
// Application.Run(f);
// }
private void btnClose_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void frmViewResult_Load(object sender, System.EventArgs e)
{
this.cboSubject.Items.Add("Java");
this.cboSubject.Items.Add("C#");
this.cboSubject.Items.Add("SQL Server");
this.cboSubject.Items.Add("Html");
searchvalue[0]= "";
searchvalue[1]="";
searchvalue[2]="";
searchvalue[3]="";
}
//修改情况:部门:ACCP产品开发培训部 修改人:王文 时间:2004-12-25
private void btnSearch_Click(object sender, System.EventArgs e)
{
searchvalue[0]=this.dtpFrom.Value.ToString("dd/MM/yyyy");
searchvalue[1]=this.dtpTo.Value.ToString("dd/MM/yyyy");
searchvalue[2]=this.cboSubject.Text;
searchvalue[3]=frmLogin.userid;
DataTable dt2=objExam.FetchStudentResults(searchvalue);
if(dt2.Rows.Count==0)
{
//除去MessageBox.Show("No Records Found");
//所添加的CODES
this.dbgStudent.DataSource = null;
}
else
{
this.dbgStudent.DataSource=dt2;
}
}
private void pDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
DataTable dt=(DataTable)this.dbgStudent.DataSource;
Datagridprinter objDGP = new Datagridprinter(this.dbgStudent, pDoc,dt);
objDGP.PageNumber = 1;
objDGP.RowCount = 0;
Graphics g = e.Graphics;
DrawTopLabel(g);
bool more = objDGP.DrawDataGrid(g);
if (more == true)
{
e.HasMorePages = true;
objDGP.PageNumber++;
}
}
catch(Exception excep)
{
MessageBox.Show("打印时发生错误:" +excep.Message.ToString());
}
}
void DrawTopLabel(Graphics g)
{
int TopMargin = pDoc.DefaultPageSettings.Margins.Top;
// lblHeading.Text ="Stock Information";
// g.FillRectangle(new SolidBrush(lblHeading.BackColor), lblHeading.Location.X, lblHeading.Location.Y + TopMargin, lblHeading.Size.Width, 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.dbgStudent.DataSource;
// Datagridprinter objDGP = new Datagridprinter(this.dbgStudent, pDoc,dt);
// Datagridprinter.PageNumber = 1;
// Datagridprinter.RowCount = 0;
if (pdlgStudent.ShowDialog() == DialogResult.OK)
{
pDoc.Print();
}
}
catch(Exception excep)
{
MessageBox.Show("打印时发生错误" +excep.Message.ToString());
}
}
private void button1_Click(object sender, System.EventArgs e)
{
this.ppdlgStudent.ShowDialog();
}
private void btnHelp_Click(object sender, System.EventArgs e)
{
Help.ShowHelp(this,Environment.CurrentDirectory +@"\\OES_Help\OES_Help.chm");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -