北京安通林JIS系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

120 lines
3.9 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Stone.Common;
using Gm_WMS.DataAccess.DataService;
namespace Stone.WinModule.Report
{
public partial class frmReport1 : Stone.WinModule.frmBase
{
private LocalDBService db = null;
public frmReport1()
{
InitializeComponent();
db = new LocalDBService();
}
private void frmReport1_Load(object sender, EventArgs e)
{
try
{
UpdateGrid();
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void tlbRefresh_Click(object sender, EventArgs e)
{
try
{
UpdateGrid();
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void tlbOutPut_Click(object sender, EventArgs e)
{
MyExport.ShowExport(this.dgrdView);
}
private void tlbExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnSerach_Click(object sender, EventArgs e)
{
try
{
UpdateGrid();
}
catch (Exception ex)
{
MyMessageBox.ShowErrorMessage(ex.Message);
}
}
private void UpdateGrid()
{
string sql = @"
SELECT ManufactorCode, ManufactorName, ModelCode, ModelName, ProductName, ProductMemo, Custom1, Custom2, ISNULL(SUM(Qty), 0) AS Qty
FROM dbo.t_BarCode
WHERE [AddTime] >= '{0}' and [AddTime] <= '{1}' and ({2})
GROUP BY ManufactorCode, ManufactorName, ModelName, ModelCode, ProductName, ProductMemo, Custom1, Custom2
ORDER BY ManufactorName, ModelName
";
string code = this.txtCode.Text.Trim();
string d1 = this.txtD1.Value.ToString("yyyy-MM-dd 00:00:00");
string d2 = this.txtD2.Value.ToString("yyyy-MM-dd 23:59:59");
string strWhere = "1=1";
if (code != "")
{
strWhere = "[ManufactorCode] like '%" + code + "%' or ";
strWhere += "[ManufactorName] like '%" + code + "%' or ";
strWhere += "[ModelCode] like '%" + code + "%' or ";
strWhere += "[ModelName] like '%" + code + "%' or ";
strWhere += "[ProductName] like '%" + code + "%' or ";
strWhere += "[ProductMemo] like '%" + code + "%' or ";
strWhere += "[Custom1] like '%" + code + "%' or ";
strWhere += "[Custom2] like '%" + code + "%' ";
}
sql = string.Format(sql, d1, d2, strWhere);
DataTable dtData = db.Exec_DataSet(sql).Tables[0];
this.dgrdView.DataSource = dtData;
this.dgrdView.Columns["ManufactorCode"].HeaderText = "厂家代码";
this.dgrdView.Columns["ManufactorName"].HeaderText = "厂家名称";
this.dgrdView.Columns["ModelCode"].HeaderText = "车型代码";
this.dgrdView.Columns["ModelName"].HeaderText = "车型名称";
this.dgrdView.Columns["ProductName"].HeaderText = "件号";
this.dgrdView.Columns["ProductMemo"].HeaderText = "产品备注";
this.dgrdView.Columns["Custom1"].HeaderText = "自定义1";
this.dgrdView.Columns["Custom2"].HeaderText = "自定义2";
this.dgrdView.Columns["Qty"].HeaderText = "数量";
this.lblStateRecord.Text = "记录数:" + dtData.Rows.Count;
MyGridViewStyle.SetDataGridMenuCommon(this.dgrdView);
}
}
}