?? financialreport.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 財務管理系統
{
/// <summary>
/// BalanceSheet 的摘要說明。
/// </summary>
public class FinancialReport : System.Windows.Forms.Form
{
private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnSummary;
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public FinancialReport()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnSummary = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.SuspendLayout();
//
// crystalReportViewer1
//
this.crystalReportViewer1.ActiveViewIndex = -1;
this.crystalReportViewer1.DisplayGroupTree = false;
this.crystalReportViewer1.Location = new System.Drawing.Point(0, 48);
this.crystalReportViewer1.Name = "crystalReportViewer1";
this.crystalReportViewer1.ReportSource = null;
this.crystalReportViewer1.Size = new System.Drawing.Size(664, 440);
this.crystalReportViewer1.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnSummary);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.numericUpDown1);
this.groupBox1.Location = new System.Drawing.Point(8, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(648, 48);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
//
// btnSummary
//
this.btnSummary.Location = new System.Drawing.Point(416, 15);
this.btnSummary.Name = "btnSummary";
this.btnSummary.Size = new System.Drawing.Size(120, 23);
this.btnSummary.TabIndex = 2;
this.btnSummary.Text = "顯示報表";
this.btnSummary.Click += new System.EventHandler(this.btnSummary_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(88, 19);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(152, 16);
this.label1.TabIndex = 1;
this.label1.Text = "選擇要統計的會計期間";
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(256, 16);
this.numericUpDown1.Minimum = new System.Decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.TabIndex = 0;
this.numericUpDown1.Value = new System.Decimal(new int[] {
1,
0,
0,
0});
//
// FinancialReport
//
this.AcceptButton = this.btnSummary;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(664, 493);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.crystalReportViewer1);
this.Name = "FinancialReport";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "資產負債表";
this.Load += new System.EventHandler(this.FinancialReport_Load);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
}
#endregion
//------------讀入系統參數中的當前會計期間-----------
private void FinancialReport_Load(object sender, System.EventArgs e)
{
string conStr="workstation id=localhost;Integrated Security=SSPI;Database=caiwubook;";
SqlConnection cn=new SqlConnection(conStr);
cn.Open();
//讀入當前會計期間
SqlCommand cmd=cn.CreateCommand();
cmd.CommandText="select 取值 from 系統參數表 where 編號='3'";
this.numericUpDown1.Value=Convert.ToDecimal(cmd.ExecuteScalar());
}
//----------顯示所選擇的會計期間的報表--------------
private void btnSummary_Click(object sender, System.EventArgs e)
{
string conStr="workstation id=localhost;Integrated Security=SSPI;Database=caiwubook;";
SqlConnection cn=new SqlConnection(conStr);
cn.Open();
//調用儲存過程,計算當前會計期間的資產負債表
SqlCommand cmd=cn.CreateCommand();
int index=Convert.ToInt32(this.numericUpDown1.Value);
cmd.CommandText="exec sf_計算資產負債表 "+index.ToString();
cmd.ExecuteNonQuery();
//顯示資產負債報表
string sql="select * from 資產負債表 where 會計期間='"+index.ToString()+"'";
SqlDataAdapter da=new SqlDataAdapter(sql,cn);
DataSet ds=new DataSet();
da.Fill(ds);
CrystalReport1 rpt=new CrystalReport1();
//連接報表數據源
rpt.SetDataSource(ds.Tables[0]);
crystalReportViewer1.ReportSource=rpt;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -