部分库存管理软件代码-2

公布部分C#编写库存管理软件代码供所有.Net开发爱好者共同学习。
代码网友可直接引用,如转载请注明出处。
http://spaces.msn.com/zhihongf/
第二部分Report,根据查询条件输出报表。
代码编写:方志洪
E-mail:zhihongf@Gmail.com
2006年2月3日。
 
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace ZhihongFang.ReportWindows
{
 /// <summary>
 /// frmPutInSingleReport 的摘要说明。
 /// </summary>
 public class frmPutInSingleReport : System.Windows.Forms.Form
 {
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;
  public frmPutInSingleReport()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();
   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }
  private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
  #region 入库单报表,窗体初始化,变量定义
  /// <summary>
  /// 入库单报表,窗体初始化。
  /// </summary>
  /// <param name="PutInID">入库记单号</param>
  public frmPutInSingleReport(string strPutInID)
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();
   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
   this.SetDataSet(strPutInID);
   PutInSingleReport oRpt=new PutInSingleReport();
   oRpt.SetDataSource(this.DataSetReport);
   this.crystalReportViewer1.ReportSource=oRpt;
  }
  #endregion
  /// <summary>
  /// 保存DataSet报表数据;
  /// </summary>
  ReportDataSet.dataSetPutInSingle DataSetReport=new ZhihongFang.ReportDataSet.dataSetPutInSingle();
  #region 根据入库单记录读取数据存入DataSet
  /// <summary>
  /// 根据入库单记录读取数据存入DataSet
  /// </summary>
  /// <param name="PutInID">入库单编号</param>
  private void SetDataSet(string PutInID)
  {
   this.DataSetReport.Clear();
   System.Data.SqlClient.SqlConnection sqlconnection = new System.Data.SqlClient.SqlConnection();
   sqlconnection.ConnectionString=AppConfig.ClassDataLinkString.DataConnection;
   try
   {
    sqlconnection.Open();
    string SQL="SELECT * FROM [入库记录] WHERE [入库单号] LIKE '"+PutInID.Trim()+"'";
    System.Data.SqlClient.SqlDataAdapter sqldataadapter = new System.Data.SqlClient.SqlDataAdapter(SQL,sqlconnection);
    sqldataadapter.Fill(this.DataSetReport,"入库记录");
    SQL="SELECT * FROM [入库明细] WHERE [入库单号] LIKE '"+PutInID.Trim()+"'";
    sqldataadapter.SelectCommand.CommandText=SQL;
    sqldataadapter.Fill(this.DataSetReport,"入库明细");
    SQL="SELECT [供货商名称],[联系人],[电话] FROM [供货商名录] WHERE [供货商编号] LIKE (SELECT [供货商编号] FROM [入库记录] WHERE [入库单号] LIKE '"+PutInID.Trim()+"')";
    sqldataadapter.SelectCommand.CommandText=SQL;
    sqldataadapter.Fill(this.DataSetReport,"供货商名录");
   }
   catch(System.Exception ex)
   {
    MessageBox.Show(ex.ToString());
   }
   finally
   {
    sqlconnection.Close();
   }
  }
  #endregion
  /// <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()
  {
   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmPutInSingleReport));
   this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
   this.SuspendLayout();
   //
   // crystalReportViewer1
   //
   this.crystalReportViewer1.ActiveViewIndex = -1;
   this.crystalReportViewer1.DisplayGroupTree = false;
   this.crystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
   this.crystalReportViewer1.Location = new System.Drawing.Point(0, 0);
   this.crystalReportViewer1.Name = "crystalReportViewer1";
   this.crystalReportViewer1.ReportSource = null;
   this.crystalReportViewer1.ShowCloseButton = false;
   this.crystalReportViewer1.ShowGroupTreeButton = false;
   this.crystalReportViewer1.Size = new System.Drawing.Size(720, 470);
   this.crystalReportViewer1.TabIndex = 0;
   //
   // frmPutInSingleReport
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(720, 470);
   this.Controls.Add(this.crystalReportViewer1);
   this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
   this.Name = "frmPutInSingleReport";
   this.ShowInTaskbar = false;
   this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
   this.Text = "产品入库记录单";
   this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
   this.Load += new System.EventHandler(this.frmPutInSingleReport_Load);
   this.ResumeLayout(false);
  }
  #endregion
  private void frmPutInSingleReport_Load(object sender, System.EventArgs e)
  {
 
  }
 }
}
 
=======================================================
对以上代码网友如有建议或更好的实现方法可与我联系。
方志洪
E-mail:zhihongf@gmail.com
2006年2月3日。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值