118 lines
4.5 KiB
C#
118 lines
4.5 KiB
C#
using System;
|
||
using System.IO;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using System.Collections;
|
||
|
||
namespace CheckTool
|
||
{
|
||
public partial class Form1 : Form
|
||
{
|
||
private string _SERVERPARTCODE = System.Configuration.ConfigurationManager.AppSettings["SERVERPARTCODE"].ToString();
|
||
private string _SHOPCODE = System.Configuration.ConfigurationManager.AppSettings["SHOPCODE"].ToString();
|
||
public Form1()
|
||
{
|
||
InitializeComponent();
|
||
this.StartPosition = FormStartPosition.CenterScreen;
|
||
}
|
||
|
||
private void BtnTransfer_Click(object sender, EventArgs e)
|
||
{
|
||
int RowNum = 1;
|
||
int CheckedCount = 3;
|
||
if (CheckInfo.Text.Trim() == "")
|
||
return;
|
||
DataTable _CopyDataTable = new DataTable();
|
||
_CopyDataTable.Columns.Add("序号");
|
||
if (ListCode.Checked)
|
||
{
|
||
_CopyDataTable.Columns.Add("单号");
|
||
CheckedCount++;
|
||
}
|
||
_CopyDataTable.Columns.Add("商品条码");
|
||
if (StockCode.Checked)
|
||
{
|
||
_CopyDataTable.Columns.Add("库存批次");
|
||
CheckedCount++;
|
||
}
|
||
_CopyDataTable.Columns.Add("库存数量");
|
||
if (CheckDate.Checked)
|
||
{
|
||
_CopyDataTable.Columns.Add("盘点时间");
|
||
CheckedCount++;
|
||
}
|
||
if (MashineCode.Checked)
|
||
{
|
||
_CopyDataTable.Columns.Add("机器号");
|
||
CheckedCount++;
|
||
}
|
||
foreach (string str in CheckInfo.Text.Split('\n'))
|
||
{
|
||
if ((ListCode.Checked ? str.Split(',')[1].ToString() : str.Split(',')[0].ToString()).Trim() == "")
|
||
continue;
|
||
DataRow _DataRow = _CopyDataTable.NewRow();
|
||
for (int i = 0; (i <= str.Split(',').Length && i < CheckedCount); i++)
|
||
{
|
||
if (i == 0)
|
||
{
|
||
_DataRow[i] = RowNum.ToString();
|
||
RowNum++;
|
||
}
|
||
else
|
||
_DataRow[i] = str.Split(',')[i - 1].ToString().Replace("\r", "");
|
||
}
|
||
_CopyDataTable.Rows.Add(_DataRow);
|
||
}
|
||
dataGridView1.DataSource = _CopyDataTable;
|
||
}
|
||
|
||
private void BtnCorrect_Click(object sender, EventArgs e)
|
||
{
|
||
DataTable dt = DbHelper.QueryOdbc(@"SELECT * FROM T_SELLDATA WHERE SELLDATA_DATE > (
|
||
SELECT MAX(ENDACCOUNT_DATE) FROM T_ENDACCOUNT WHERE SERVERPARTCODE = '" + _SERVERPARTCODE + "' AND SHOPCODE = '" +
|
||
_SHOPCODE + "') AND SERVERPARTCODE = '" + _SERVERPARTCODE + "' AND SHOPCODE = '" + _SHOPCODE + "'").Tables[0];
|
||
FileStream _FileStream;
|
||
if (!File.Exists("d://销售数据.txt"))
|
||
{
|
||
_FileStream = new FileStream("d://销售数据.txt", FileMode.CreateNew);
|
||
}
|
||
else
|
||
_FileStream = new FileStream("d://销售数据.txt", FileMode.Open);
|
||
StreamWriter _StreamWriter = new StreamWriter(_FileStream);
|
||
string WriteTxt = "";
|
||
foreach (DataColumn _DataColumn in dt.Columns)
|
||
{
|
||
WriteTxt += (WriteTxt == "" ? "" : ",") + _DataColumn.ColumnName;
|
||
}
|
||
foreach (DataRow dr in dt.Rows)
|
||
{
|
||
WriteTxt += "\r\n";
|
||
for (int i = 0; i < dr.ItemArray.Length; i++)
|
||
{
|
||
if (i == 0)
|
||
WriteTxt += dr[i].ToString();
|
||
else
|
||
WriteTxt += "," + dr[i].ToString();
|
||
}
|
||
}
|
||
_StreamWriter.Write(WriteTxt);
|
||
_StreamWriter.Close();
|
||
MessageBox.Show("导出成功!文件位置:d://销售数据.txt");
|
||
}
|
||
|
||
private void BtnGetDatas_Click(object sender, EventArgs e)
|
||
{
|
||
DataTable dt = DbHelper.QueryOdbc(@"SELECT * FROM T_SELLDATA WHERE SELLDATA_DATE > (
|
||
SELECT MAX(ENDACCOUNT_DATE) FROM T_ENDACCOUNT WHERE SERVERPARTCODE = '" + _SERVERPARTCODE + "' AND SHOPCODE = '" +
|
||
_SHOPCODE + "') AND SERVERPARTCODE = '" + _SERVERPARTCODE + "' AND SHOPCODE = '" + _SHOPCODE + "'").Tables[0];
|
||
dataGridView1.DataSource = dt;
|
||
MessageBox.Show("获取成功!");
|
||
}
|
||
}
|
||
}
|