1887 lines
113 KiB
C#
1887 lines
113 KiB
C#
using System;
|
||
using System.Collections;
|
||
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.Threading;
|
||
using Newtonsoft.Json.Linq;
|
||
using RunUpdateExe;
|
||
using System.Diagnostics;
|
||
using System.IO;
|
||
|
||
namespace InvoicingTool
|
||
{
|
||
public partial class CheckCommodity : Form
|
||
{
|
||
BackgroundWorker CheckWorker = new BackgroundWorker();
|
||
QualityHelper _QualityHelper = new QualityHelper();
|
||
WaiteFrom _WaitForm;
|
||
private string _serverpartshop_id { get; set; }
|
||
private string _serverpartcode { get; set; }
|
||
private string _shopcode { get; set; }
|
||
private string _machinecode { get; set; }
|
||
private string _sellworkername { get; set; }
|
||
public string CheckDate { get; set; }
|
||
public CheckCommodity()
|
||
{
|
||
InitializeComponent();
|
||
CheckWorker.WorkerReportsProgress = true;
|
||
CheckWorker.WorkerSupportsCancellation = true;
|
||
CheckWorker.DoWork += CheckWorkerDoWork_Handler;
|
||
CheckWorker.ProgressChanged += ProgressChanged_Handler;
|
||
CheckWorker.RunWorkerCompleted += RunWorkerCompleted_Handler;
|
||
_serverpartshop_id = _QualityHelper.serverpartshop_id;
|
||
|
||
//ShowWaiteForm();
|
||
//_WaitForm.ShowMessage("正在验证日结信息......");
|
||
//APPLoading();
|
||
|
||
//_WaitForm.Close();
|
||
//_WaitForm.Dispose();
|
||
}
|
||
public void ShowWaiteForm()
|
||
{
|
||
_WaitForm = WaiteFrom.GetInstance();
|
||
//设置WaitForm的父窗体为当前窗体,以便在WaitForm中使用父窗体对象
|
||
_WaitForm.TopMost = true;
|
||
_WaitForm.Owner = this;
|
||
_WaitForm.ShowMessage("加载中......");
|
||
_WaitForm.Show();
|
||
Application.DoEvents();
|
||
_WaitForm.Refresh();
|
||
}
|
||
/// <summary>
|
||
/// 程序初始化检查
|
||
/// </summary>
|
||
private void APPLoading()
|
||
{
|
||
ArrayList listmode = new ArrayList();
|
||
listmode.Insert(0, "请选择盘点模式");
|
||
listmode.Add("重新盘点");
|
||
listmode.Add("实时盘点");
|
||
listmode.Add("仓库盘点");
|
||
cobCHECKMODE.DataSource = listmode;
|
||
cobCHECKMODE.Text = "仓库盘点";
|
||
lblCheckMode.Text = "仓库盘点";
|
||
ArrayList listDifference = new ArrayList();
|
||
listDifference.Insert(0, "全部");
|
||
listDifference.Add("损溢");
|
||
listDifference.Add("盘盈");
|
||
listDifference.Add("盘亏");
|
||
listDifference.Add("无差异");
|
||
cobDifference.DataSource = listDifference;
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
DownLoadData();
|
||
}
|
||
private void DownLoadData()
|
||
{
|
||
_serverpartcode = _QualityHelper.serverpartcode;
|
||
_shopcode = _QualityHelper.shopcode;
|
||
_machinecode = _QualityHelper.machinecode;
|
||
_sellworkername = _QualityHelper.sellworkername;
|
||
string _selectsql = "";
|
||
string _Url = "http://" + _QualityHelper.dbip + ":" + _QualityHelper.serviceport + "/Service.asmx";
|
||
//string _Url = "http://localhost:7080/EShangTechService/Service.asmx";
|
||
_selectsql = "SELECT MAX(ENDACCOUNT_DATE) FROM T_ENDACCOUNT WHERE ENDACCOUNT_DATE IS " +
|
||
"NOT NULL AND ENDACCOUNT_DATE < NOW() AND SERVERPARTCODE = '" + _serverpartcode +
|
||
"' AND SHOPCODE = '" + _shopcode + "' AND MACHINECODE = '" + _machinecode +
|
||
"' AND FLAG <> 5 ";
|
||
string checkdate = "";
|
||
try
|
||
{
|
||
checkdate = DBHelper.QueryOdbc(_selectsql).Tables[0].Rows[0][0].ToString();
|
||
}
|
||
catch
|
||
{
|
||
checkdate = "";
|
||
}
|
||
//checkdate = "2017-12-28 18:40:39";
|
||
if (checkdate != "")
|
||
{
|
||
_selectsql = "select 1 from t_checkcommoditydetail where checkcommodity_id = ( " +
|
||
"select checkcommodity_id from t_checkcommodityex where checkdate = datetime('" +
|
||
checkdate + "') and serverpartshop_id = " + _QualityHelper.serverpartshop_id + ")";
|
||
if (DBHelper.QueryOdbc(_selectsql).Tables[0].Rows.Count == 0)
|
||
{
|
||
//string[] args = { "330001", "121005", "2017/10/30 21:32:00", "驿商" };
|
||
string[] args = { _serverpartcode, _shopcode, checkdate, _sellworkername, "2000", "0", "0" };
|
||
//string[] args = { _QualityHelper.serverpartcode, _QualityHelper.shopcode, "2017/12/03 17:53:57", _QualityHelper.sellworkername, "1000" };
|
||
string _Result = "", trade_no = "", trade_num = "", result_code = "", result_desc = "";
|
||
ShowWaiteForm();
|
||
_WaitForm.ShowMessage("正在查询盘点单......");
|
||
try
|
||
{
|
||
_WaitForm.ShowMessage("正在获取盘点单......");
|
||
//_Result = WSHelper.InvokeWebService("http://localhost:7080/EShangTechService/Service.asmx", "CreateCheckBill", args).ToString();
|
||
_Result = WSHelper.InvokeWebService(_Url, "CreateCheckBill", args).ToString();
|
||
if (_Result != "")
|
||
{
|
||
JObject _JObject = JObject.Parse(_Result);
|
||
trade_no = _JObject["trade_no"].ToString();
|
||
trade_num = _JObject["trade_num"].ToString();
|
||
result_code = _JObject["result_code"].ToString();
|
||
result_desc = _JObject["result_desc"].ToString();
|
||
switch (result_code)
|
||
{
|
||
case "100":
|
||
List<string> _List = new List<string>();
|
||
DBHelper.ExecuteSqlTran("delete from t_checkcommodityex");
|
||
DBHelper.ExecuteSqlTran("delete from t_checkcommoditydetail");
|
||
using (DataSet _DataSet = JsonHelper.JsonToDataSet(RealEstate_Extend.ToDecrypt(trade_no).Replace(" ", "")))
|
||
{
|
||
if (_DataSet != null)
|
||
{
|
||
if (_DataSet.Tables.Count > 0)
|
||
{
|
||
DataTable _DataTable = _DataSet.Tables[0];
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
string _insertColumns = SqlColumns(_DataTable);
|
||
string _insertValues = "";
|
||
List<string> ValuesList = new List<string>();
|
||
foreach (DataRow _Row in _DataTable.Rows)
|
||
{
|
||
ValuesList.Add(AnySqlValues(_DataTable, _Row));
|
||
}
|
||
for (int i = 0; i < ValuesList.Count(); i++)
|
||
{
|
||
_insertValues += (_insertValues == "" ? "(" + ValuesList[i] + ")" : ",(" + ValuesList[i] + ")");
|
||
}
|
||
_List.Add("INSERT INTO T_CHECKCOMMODITYEX (" + _insertColumns + ") VALUES " + _insertValues);
|
||
int _RowCount = 0;
|
||
int.TryParse(trade_num, out _RowCount);
|
||
if (_RowCount > 0)
|
||
{
|
||
int _Rownum = 0;
|
||
do
|
||
{
|
||
_Rownum += 200;
|
||
if (_Rownum > _RowCount)
|
||
{
|
||
_WaitForm.ShowMessage("正在下载盘点明细......");
|
||
}
|
||
else
|
||
{
|
||
_WaitForm.ShowMessage("正在下载盘点明细......" + (int)((decimal)_Rownum * 100 / _RowCount) + "%");
|
||
}
|
||
string[] _args = { _serverpartcode, _shopcode, checkdate, _sellworkername, "2000", _Rownum.ToString(), "200" };
|
||
//_Result = WSHelper.InvokeWebService("http://localhost:7080/EShangTechService/Service.asmx", "CreateCheckBill", _args).ToString();
|
||
_Result = WSHelper.InvokeWebService(_Url, "CreateCheckBill", _args).ToString();
|
||
if (_Result != "")
|
||
{
|
||
_JObject = JObject.Parse(_Result);
|
||
trade_no = _JObject["trade_no"].ToString();
|
||
trade_num = _JObject["trade_num"].ToString();
|
||
result_code = _JObject["result_code"].ToString();
|
||
result_desc = _JObject["result_desc"].ToString();
|
||
using (DataSet _DetailSet = JsonHelper.JsonToDataSet(RealEstate_Extend.ToDecrypt(trade_num).Replace(" ", "")))
|
||
{
|
||
if (_DetailSet != null)
|
||
{
|
||
if (_DetailSet.Tables.Count > 0)
|
||
{
|
||
DataTable _DetailTable = _DetailSet.Tables[0];
|
||
if (_DetailTable.Rows.Count > 0)
|
||
{
|
||
_insertColumns = SqlColumns(_DetailTable);
|
||
_insertValues = "";
|
||
ValuesList.Clear();
|
||
foreach (DataRow _Row in _DetailTable.Rows)
|
||
{
|
||
ValuesList.Add(AnySqlValues(_DetailTable, _Row));
|
||
}
|
||
for (int i = 0; i < ValuesList.Count(); i++)
|
||
{
|
||
_insertValues += (_insertValues == "" ? "(" + ValuesList[i] + ")" : ",(" + ValuesList[i] + ")");
|
||
}
|
||
_List.Add("INSERT INTO T_CHECKCOMMODITYDETAIL (" + _insertColumns + ") VALUES " + _insertValues);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
DialogResult _DialogResult = MessageBox.Show("服务器连接失败,盘点功能不可用,程序将自动退出!", "系统提示",
|
||
MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
if (_DialogResult == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
DialogResult _DialogResult = MessageBox.Show("服务器连接失败,盘点功能不可用,程序将自动退出!", "系统提示",
|
||
MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
if (_DialogResult == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (MessageBox.Show("通讯异常,盘点功能暂不可用,请稍后重试", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
Thread.Sleep(500);
|
||
} while (_Rownum < _RowCount);
|
||
}
|
||
else
|
||
{
|
||
if (MessageBox.Show("盘点单明细正在生成,请稍后重试!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
if (_List.Count > 0)
|
||
{
|
||
DBHelper.ExecuteSqlTran(_List);
|
||
}
|
||
Loading();
|
||
//SearchDataView();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
DialogResult _DialogResult = MessageBox.Show("服务器连接失败,盘点功能不可用,程序将自动退出!", "系统提示",
|
||
MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
if (_DialogResult == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
DialogResult _DialogResult = MessageBox.Show("服务器连接失败,盘点功能不可用,程序将自动退出!", "系统提示",
|
||
MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
if (_DialogResult == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "101":
|
||
if (MessageBox.Show("盘点单明细正在生成,请稍后重试!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
break;
|
||
case "201":
|
||
if (MessageBox.Show("该门店已停业,不能进行盘点操作", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
break;
|
||
case "300":
|
||
if (MessageBox.Show("门店存在调拨退货业务,请前往综管平台处理!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
break;
|
||
case "301":
|
||
//Download_Click(null, null);
|
||
if (MessageBox.Show("门店正在盘存,请前往综管平台处理!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
break;
|
||
case "302":
|
||
if (MessageBox.Show("有未校验的结账信息,请前往综管平台处理!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
break;
|
||
case "303":
|
||
if (MessageBox.Show("有未扣除库存的单品信息,请前往综管平台处理!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
break;
|
||
case "304":
|
||
if (MessageBox.Show("结账信息未上传,请先上传结账信息", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
break;
|
||
case "999":
|
||
if (MessageBox.Show("通讯异常,盘点功能暂不可用,请稍后重试", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (MessageBox.Show("通讯异常,盘点功能暂不可用,请稍后重试", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteServiceLog(ex.Message);
|
||
DialogResult _DialogResult = MessageBox.Show("服务器连接失败,盘点功能不可用,程序将自动退出!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
if (_DialogResult == DialogResult.OK)
|
||
{
|
||
try
|
||
{
|
||
Process[] _Process = Process.GetProcessesByName("cashier");
|
||
if (_Process.Count() == 0)
|
||
{
|
||
string _path = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
ProcessStartInfo info = new ProcessStartInfo(_path);
|
||
info.WorkingDirectory = System.IO.Path.GetDirectoryName(_path);
|
||
Process.Start(info);
|
||
}
|
||
else
|
||
{
|
||
IntPtr _IntPtr = _Process[0].MainWindowHandle;
|
||
}
|
||
}
|
||
catch { }
|
||
}
|
||
Environment.Exit(0);
|
||
}
|
||
_WaitForm.Close();
|
||
_WaitForm.Dispose();
|
||
}
|
||
else
|
||
{
|
||
Loading();
|
||
//SearchDataView();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
DialogResult _DialogResult = MessageBox.Show("门店无结账记录,盘点功能不可用,程序将自动退出!",
|
||
"系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
if (_DialogResult == DialogResult.OK)
|
||
{
|
||
string _StartAPP = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AutoUpdateEx.exe");
|
||
if (!File.Exists(_StartAPP))
|
||
{
|
||
_StartAPP = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
}
|
||
try
|
||
{
|
||
Process.Start(_StartAPP);
|
||
}
|
||
catch { }
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 界面信息初始化
|
||
/// </summary>
|
||
private void Loading()
|
||
{
|
||
string _selectsql = "select checkcommodity_id, checkperson, checkdate, serverpart_id, serverpartshop_id," +
|
||
" checkcommodity_desc, check_state,check_passport_guid, check_type from t_checkcommodityex " +
|
||
"where check_state = 0 and serverpartshop_id = " + _QualityHelper.serverpartshop_id;
|
||
try
|
||
{
|
||
DataTable _DataTable = DBHelper.QueryOdbc(_selectsql).Tables[0];
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
CheckDate = _DataTable.Rows[0]["checkdate"].ToString();
|
||
SearchDataView();
|
||
}
|
||
else
|
||
{
|
||
CheckDate = "";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{ }
|
||
txtShopName.Text = _QualityHelper.shopname;
|
||
txtCheckDate.Text = CheckDate;
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
ChangeColor();
|
||
}
|
||
|
||
private void ProgressChanged_Handler(object sender, ProgressChangedEventArgs args)
|
||
{
|
||
progressBar1.Visible = true;
|
||
lblMessage.Visible = true;
|
||
progressBar1.Value = args.ProgressPercentage;
|
||
lblMessage.Text = "正在上传盘点数据,进度:" + args.ProgressPercentage.ToString() + "%";
|
||
}
|
||
private void CheckWorkerDoWork_Handler(object sender, DoWorkEventArgs args)
|
||
{
|
||
|
||
}
|
||
private void RunWorkerCompleted_Handler(object sender, RunWorkerCompletedEventArgs args)
|
||
{
|
||
|
||
}
|
||
/// <summary>
|
||
/// 显示盘点商品列表
|
||
/// </summary>
|
||
private void SearchDataView()
|
||
{
|
||
string _selectsql = "SELECT ROW_NUMBER() OVER (ORDER BY CHECKCOMMODITYDETAIL_ID) " +
|
||
"AS CHECKCOMMODITYDETAIL_ID, A.COMMODITY_BARCODE AS COMMODITY_BARCODE," +
|
||
"A.COMMODITY_NAME AS COMMODITY_NAME, ISNULL(A.OVERPLUSCOUNT,0) AS " +
|
||
"OVERPLUSCOUNT,ISNULL(A.CUROVERPLUSCOUNT,0) AS CUROVERPLUSCOUNT," +
|
||
"(ISNULL(A.CUROVERPLUSCOUNT,0) - ISNULL(A.OVERPLUSCOUNT,0)) AS " +
|
||
"DIFFERENCECOUNT,A.CHECKDATE AS CHECKDATE " +
|
||
"FROM T_CHECKCOMMODITYDETAIL A,T_CHECKCOMMODITYEX B " +
|
||
"WHERE A.CHECKCOMMODITY_ID = B.CHECKCOMMODITY_ID AND " +
|
||
"B.CHECK_STATE = 0 AND B.SERVERPARTSHOP_ID = " + _serverpartshop_id +
|
||
"ORDER BY CHECKCOMMODITYDETAIL_ID";
|
||
DataTable _DataTable = DBHelper.QueryOdbc(_selectsql).Tables[0];
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
//for (int i = 0; i < _DataTable.Rows.Count; i++)
|
||
//{
|
||
// _DataTable.Rows[i]["checkcommoditydetail_id"] = i + 1;
|
||
//}
|
||
CheckView.DataSource = _DataTable;
|
||
CheckView.Rows[_DataTable.Rows.Count - 1].Selected = true;
|
||
CheckView.CurrentCell = CheckView.Rows[_DataTable.Rows.Count - 1].Cells[0];
|
||
ChangeColor();
|
||
cobDifference_SelectionChangeCommitted(null, null);
|
||
}
|
||
}
|
||
|
||
#region 保存商品盘点信息
|
||
/// <summary>
|
||
/// 保存商品盘点记录
|
||
/// </summary>
|
||
/// <param name="BarCode">商品条码</param>
|
||
/// <param name="CuroverPlusCount">盘点数量</param>
|
||
/// <param name="InventoryDateTime">盘点时间</param>
|
||
/// <param name="InventoryType">盘点类型</param>
|
||
private void CommodityInput(string BarCode, string CuroverPlusCount, string InventoryDateTime, string InventoryType)
|
||
{
|
||
List<string> _List = new List<string>();
|
||
//string _selectsql = "select count(*) from t_checkcommodityex where check_state = 0 and " +
|
||
// "serverpartshop_id = " + _QualityHelper.serverpartshop_id;
|
||
try
|
||
{
|
||
//if (DBHelper.QueryOdbc(_selectsql).Tables[0].Rows[0][0].ToString() == "0")
|
||
//{
|
||
// DialogResult _DialogResult = MessageBox.Show("未查询到盘点单,请先下载盘点单信息!", "系统提示", MessageBoxButtons.OK,
|
||
// MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
// if (_DialogResult == DialogResult.OK)
|
||
// {
|
||
// CommodityInfo.Clear();
|
||
// CommodityInfo.Focus();
|
||
// CommodityInfo.SelectAll();
|
||
// return;
|
||
// }
|
||
//}
|
||
string _selectsql = "select a.checkcommoditydetail_id, a.checkcommodity_id, a.serverpartstock_id, isnull(a.overpluscount,0) as overpluscount, " +
|
||
"a.checkdate, a.commodity_id, a.commodity_code, isnull(a.curoverpluscount,0) as curoverpluscount, a.commodity_barcode, " +
|
||
"a.checkdesc, a.commodity_name, a.commodity_salecount, isnull(a.commodity_totalcount,0) as commodity_totalcount, a.start_date, " +
|
||
"a.end_date, a.serverpart_id, a.lastoverpluscount, a.storage_count, a.out_count, a.sale_count " +
|
||
"from t_checkcommoditydetail a,t_checkcommodityex b " +
|
||
"where a.checkcommodity_id = b.checkcommodity_id and b.check_state = 0 and " +
|
||
"b.serverpartshop_id = " + _serverpartshop_id + " and a.commodity_barcode = '" + BarCode + "'";
|
||
DataTable _DataTable = DBHelper.QueryOdbc(_selectsql).Tables[0];
|
||
if (_DataTable.Rows.Count == 0)
|
||
{
|
||
//MessageBox.Show("该商品无库存信息", "系统提示", MessageBoxButtons.OK,
|
||
// MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
_selectsql = "select isnull(sum(a.sellcount),0) as sellcount from t_selldata a,t_commodityex b where a.commodity_code = b.commodity_code " +
|
||
"and b.serverpartshop_id = " + _serverpartshop_id + " and b.commodity_barcode = '" + BarCode + "' and a.selldata_date between datetime('" +
|
||
CheckDate + "') and datetime('" + InventoryDateTime + "')";
|
||
decimal SellCount = decimal.Parse(DBHelper.QueryOdbc(_selectsql).Tables[0].Rows[0]["sellcount"].ToString());
|
||
string _updatesql = "";
|
||
switch (InventoryType)
|
||
{
|
||
case "重新盘点":
|
||
_updatesql = "update t_checkcommoditydetail set curoverpluscount = " + (decimal.Parse(CuroverPlusCount) + SellCount) +
|
||
",commodity_salecount = " + SellCount + ",commodity_totalcount = " + decimal.Parse(CuroverPlusCount) +
|
||
",checkdate = datetime('" + InventoryDateTime + "'),checkdesc = '已盘点' " +
|
||
"where commodity_barcode = '" + BarCode + "' and checkcommodity_id = (select checkcommodity_id " +
|
||
"from t_checkcommodityex where check_state = 0 and serverpartshop_id = " + _QualityHelper.serverpartshop_id + ")";
|
||
_List.Add(_updatesql);
|
||
txtCheckCount.Text = (decimal.Parse(CuroverPlusCount) + SellCount).ToString("F2");
|
||
txtInventoryDate.Text = InventoryDateTime;
|
||
txtCommodityNum.Text = decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString()).ToString("F2");
|
||
txtDifferenceCount.Text = (decimal.Parse(CuroverPlusCount) + SellCount - decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString())).ToString("F2");
|
||
txtCommodityBarCode.Text = _DataTable.Rows[0]["commodity_barcode"].ToString();
|
||
txtCommodityName.Text = _DataTable.Rows[0]["commodity_name"].ToString();
|
||
break;
|
||
case "实时盘点":
|
||
_updatesql = "update t_checkcommoditydetail set curoverpluscount = isnull(commodity_totalcount,0) + " + (decimal.Parse(CuroverPlusCount) +
|
||
SellCount) + ",commodity_salecount = " + SellCount + ",commodity_totalcount = isnull(commodity_totalcount,0) + " + decimal.Parse(CuroverPlusCount) +
|
||
",checkdate = datetime('" + InventoryDateTime + "'),checkdesc = '已盘点' where commodity_barcode = '" + BarCode + "' and checkcommodity_id = " +
|
||
"(select checkcommodity_id from t_checkcommodityex where check_state = 0 and serverpartshop_id = " + _QualityHelper.serverpartshop_id + ")";
|
||
_List.Add(_updatesql);
|
||
txtCheckCount.Text = (decimal.Parse(_DataTable.Rows[0]["curoverpluscount"].ToString()) +
|
||
decimal.Parse(CuroverPlusCount) + SellCount).ToString("F2");
|
||
txtInventoryDate.Text = InventoryDateTime;
|
||
txtCommodityNum.Text = decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString()).ToString("F2");
|
||
txtDifferenceCount.Text = (decimal.Parse(_DataTable.Rows[0]["curoverpluscount"].ToString()) +
|
||
decimal.Parse(CuroverPlusCount) + SellCount - decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString())).ToString("F2");
|
||
txtCommodityBarCode.Text = _DataTable.Rows[0]["commodity_barcode"].ToString();
|
||
txtCommodityName.Text = _DataTable.Rows[0]["commodity_name"].ToString();
|
||
break;
|
||
case "仓库盘点":
|
||
_updatesql = "update t_checkcommoditydetail set curoverpluscount = isnull(commodity_salecount,0) + isnull(commodity_totalcount,0) +" +
|
||
decimal.Parse(CuroverPlusCount) + ",commodity_totalcount = isnull(commodity_totalcount,0) + " + decimal.Parse(CuroverPlusCount) +
|
||
",checkdate = datetime('" + InventoryDateTime + "'),checkdesc = '已盘点' where commodity_barcode = '" + BarCode + "' and checkcommodity_id = " +
|
||
"(select checkcommodity_id from t_checkcommodityex where check_state = 0 and serverpartshop_id = " + _QualityHelper.serverpartshop_id + ")";
|
||
_List.Add(_updatesql);
|
||
txtCheckCount.Text = (decimal.Parse(CuroverPlusCount) + SellCount).ToString("F2");
|
||
txtInventoryDate.Text = InventoryDateTime;
|
||
txtCommodityNum.Text = decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString()).ToString("F2");
|
||
txtDifferenceCount.Text = (decimal.Parse(CuroverPlusCount) + SellCount - decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString())).ToString("F2");
|
||
txtCommodityBarCode.Text = _DataTable.Rows[0]["commodity_barcode"].ToString();
|
||
txtCommodityName.Text = _DataTable.Rows[0]["commodity_name"].ToString();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
if (_List.Count() > 0)
|
||
{
|
||
DBHelper.ExecuteSqlTran(_List);
|
||
}
|
||
SearchDataView();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show("数据库连接失败,请重启收银机后重试!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
}
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
}
|
||
/// <summary>
|
||
/// 保存未匹配商品盘点记录
|
||
/// </summary>
|
||
/// <param name="BarCode">商品条码</param>
|
||
/// <param name="CuroverPlusCount">盘点数量</param>
|
||
/// <param name="InventoryDateTime">盘点时间</param>
|
||
/// <param name="InventoryType">盘点类型</param>
|
||
private void CommodityInputUnmatch(string BarCode, string CuroverPlusCount, string InventoryDateTime, string InventoryType)
|
||
{
|
||
List<string> _List = new List<string>();
|
||
try
|
||
{
|
||
string _selectsql = " SELECT DISTINCT A.CHECKCOMMODITY_ID, A.START_DATE, A.END_DATE, " +
|
||
"A.SERVERPART_ID FROM T_CHECKCOMMODITYDETAIL A,T_CHECKCOMMODITYEX B " +
|
||
"WHERE A.CHECKCOMMODITY_ID = B.CHECKCOMMODITY_ID AND B.CHECK_STATE = 0 " +
|
||
"AND B.SERVERPARTSHOP_ID = " + _serverpartshop_id;
|
||
DataTable _DataTable = DBHelper.QueryOdbc(_selectsql).Tables[0];
|
||
if (_DataTable.Rows.Count == 0)
|
||
{
|
||
//MessageBox.Show("该商品无库存信息", "系统提示", MessageBoxButtons.OK,
|
||
// MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
string _CHECKCOMMODITY_ID = _DataTable.Rows[0]["CHECKCOMMODITY_ID"].ToString();
|
||
string _START_DATE = _DataTable.Rows[0]["START_DATE"].ToString();
|
||
string _END_DATE = _DataTable.Rows[0]["END_DATE"].ToString();
|
||
string _SERVERPART_ID = _DataTable.Rows[0]["SERVERPART_ID"].ToString();
|
||
|
||
_selectsql = "select isnull(sum(a.sellcount),0) as sellcount from t_selldata a,t_commodityex b where a.commodity_code = b.commodity_code " +
|
||
"and b.serverpartshop_id = " + _serverpartshop_id + " and b.commodity_barcode = '" + BarCode + "' and a.selldata_date between datetime('" +
|
||
CheckDate + "') and datetime('" + InventoryDateTime + "')";
|
||
decimal SellCount = decimal.Parse(DBHelper.QueryOdbc(_selectsql).Tables[0].Rows[0]["sellcount"].ToString());
|
||
_selectsql = "select a.checkcommodityunmatch_id, a.checkcommodity_id, a.serverpartstock_id, isnull(a.overpluscount,0) as overpluscount, " +
|
||
"a.checkdate, a.commodity_id, a.commodity_code, isnull(a.curoverpluscount,0) as curoverpluscount, a.commodity_barcode, " +
|
||
"a.checkdesc, a.commodity_name, a.commodity_salecount, isnull(a.commodity_totalcount,0) as commodity_totalcount, a.start_date, " +
|
||
"a.end_date, a.serverpart_id, a.lastoverpluscount, a.storage_count, a.out_count, a.sale_count " +
|
||
"from t_checkcommodityunmatch a,t_checkcommodityex b " +
|
||
"where a.checkcommodity_id = b.checkcommodity_id and b.check_state = 0 and " +
|
||
"b.serverpartshop_id = " + _serverpartshop_id + " and a.commodity_barcode = '" + BarCode + "'";
|
||
_DataTable = DBHelper.QueryOdbc(_selectsql).Tables[0];
|
||
if (_DataTable.Rows.Count == 0)
|
||
{
|
||
int _Maxid = 0;
|
||
try
|
||
{
|
||
_Maxid = int.Parse(DBHelper.QueryOdbc("select max(checkcommodityunmatch_id) from t_checkcommodityunmatch").Tables[0].Rows[0][0].ToString());
|
||
}
|
||
catch
|
||
{
|
||
_Maxid = 0;
|
||
}
|
||
_selectsql = "SELECT COMMODITY_CODE,COMMODITY_NAME FROM T_COMMODITYEX " +
|
||
"WHERE COMMODITY_BARCODE = '" + BarCode + "' AND SERVERPARTSHOP_ID = " + _serverpartshop_id;
|
||
DataTable _CommodityTable = DBHelper.QueryOdbc(_selectsql).Tables[0];
|
||
if (_CommodityTable.Rows.Count > 0)
|
||
{
|
||
string _Insertsql = "INSERT INTO T_CHECKCOMMODITYUNMATCH (CHECKCOMMODITYUNMATCH_ID," +
|
||
"CHECKCOMMODITY_ID,OVERPLUSCOUNT,CHECKDATE,COMMODITY_CODE,COMMODITY_BARCODE," +
|
||
"COMMODITY_NAME,CUROVERPLUSCOUNT,COMMODITY_SALECOUNT," +
|
||
"COMMODITY_TOTALCOUNT,START_DATE,END_DATE,SERVERPART_ID ) VALUES " +
|
||
"(" + (_Maxid + 1) + "," + _CHECKCOMMODITY_ID + ",0,DATETIME('" + InventoryDateTime + "'),'" +
|
||
_CommodityTable.Rows[0]["COMMODITY_CODE"].ToString() + "','" + BarCode +
|
||
"','" + _CommodityTable.Rows[0]["COMMODITY_NAME"].ToString() + "'," +
|
||
(decimal.Parse(CuroverPlusCount) + SellCount) + "," + SellCount + "," + decimal.Parse(CuroverPlusCount) +
|
||
",DATETIME('" + _START_DATE + "'),DATETIME('" + _END_DATE + "')," + _SERVERPART_ID + ")";
|
||
_List.Add(_Insertsql);
|
||
}
|
||
else
|
||
{
|
||
string _Insertsql = "INSERT INTO T_CHECKCOMMODITYUNMATCH (CHECKCOMMODITYUNMATCH_ID," +
|
||
"CHECKCOMMODITY_ID,OVERPLUSCOUNT,CHECKDATE,COMMODITY_BARCODE," +
|
||
"CUROVERPLUSCOUNT,COMMODITY_SALECOUNT,COMMODITY_TOTALCOUNT," +
|
||
"START_DATE,END_DATE,SERVERPART_ID ) VALUES (" + (_Maxid + 1) +
|
||
"," + _CHECKCOMMODITY_ID + ",0,DATETIME('" + InventoryDateTime +
|
||
"'),'" + BarCode + "'," + (decimal.Parse(CuroverPlusCount) + SellCount) +
|
||
"," + SellCount + "," + decimal.Parse(CuroverPlusCount) +
|
||
",DATETIME('" + _START_DATE + "'),DATETIME('" + _END_DATE + "')," + _SERVERPART_ID + ")";
|
||
_List.Add(_Insertsql);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
string _updatesql = "";
|
||
switch (InventoryType)
|
||
{
|
||
case "重新盘点":
|
||
_updatesql = "update t_checkcommodityunmatch set curoverpluscount = " + (decimal.Parse(CuroverPlusCount) + SellCount) +
|
||
",commodity_salecount = " + SellCount + ",commodity_totalcount = " + decimal.Parse(CuroverPlusCount) +
|
||
",checkdate = datetime('" + InventoryDateTime + "') where commodity_barcode = '" + BarCode + "' and checkcommodity_id = " +
|
||
"(select checkcommodity_id from t_checkcommodityex where check_state = 0 and serverpartshop_id = " + _QualityHelper.serverpartshop_id + ")";
|
||
_List.Add(_updatesql);
|
||
txtCheckCount.Text = (decimal.Parse(CuroverPlusCount) + SellCount).ToString("F2");
|
||
txtInventoryDate.Text = InventoryDateTime;
|
||
txtCommodityNum.Text = decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString()).ToString("F2");
|
||
txtDifferenceCount.Text = (decimal.Parse(CuroverPlusCount) + SellCount - decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString())).ToString("F2");
|
||
txtCommodityBarCode.Text = _DataTable.Rows[0]["commodity_barcode"].ToString();
|
||
txtCommodityName.Text = _DataTable.Rows[0]["commodity_name"].ToString();
|
||
break;
|
||
case "实时盘点":
|
||
_updatesql = "update t_checkcommodityunmatch set curoverpluscount = isnull(commodity_totalcount,0) + " + (decimal.Parse(CuroverPlusCount) +
|
||
SellCount) + ",commodity_salecount = " + SellCount + ",commodity_totalcount = isnull(commodity_totalcount,0) + " + decimal.Parse(CuroverPlusCount) +
|
||
",checkdate = datetime('" + InventoryDateTime + "') where commodity_barcode = '" + BarCode + "' and checkcommodity_id = " +
|
||
"(select checkcommodity_id from t_checkcommodityex where check_state = 0 and serverpartshop_id = " + _QualityHelper.serverpartshop_id + ")";
|
||
_List.Add(_updatesql);
|
||
txtCheckCount.Text = (decimal.Parse(_DataTable.Rows[0]["curoverpluscount"].ToString()) +
|
||
decimal.Parse(CuroverPlusCount) + SellCount).ToString("F2");
|
||
txtInventoryDate.Text = InventoryDateTime;
|
||
txtCommodityNum.Text = decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString()).ToString("F2");
|
||
txtDifferenceCount.Text = (decimal.Parse(_DataTable.Rows[0]["curoverpluscount"].ToString()) +
|
||
decimal.Parse(CuroverPlusCount) + SellCount - decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString())).ToString("F2");
|
||
txtCommodityBarCode.Text = _DataTable.Rows[0]["commodity_barcode"].ToString();
|
||
txtCommodityName.Text = _DataTable.Rows[0]["commodity_name"].ToString();
|
||
break;
|
||
case "仓库盘点":
|
||
_updatesql = "update t_checkcommodityunmatch set curoverpluscount = isnull(commodity_salecount,0) + isnull(commodity_totalcount,0) +" +
|
||
decimal.Parse(CuroverPlusCount) + ",commodity_totalcount = isnull(commodity_totalcount,0) + " + decimal.Parse(CuroverPlusCount) +
|
||
",checkdate = datetime('" + InventoryDateTime + "') where commodity_barcode = '" + BarCode + "' and checkcommodity_id = " +
|
||
"(select checkcommodity_id from t_checkcommodityex where check_state = 0 and serverpartshop_id = " + _QualityHelper.serverpartshop_id + ")";
|
||
_List.Add(_updatesql);
|
||
txtCheckCount.Text = (decimal.Parse(CuroverPlusCount) + SellCount).ToString("F2");
|
||
txtInventoryDate.Text = InventoryDateTime;
|
||
txtCommodityNum.Text = decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString()).ToString("F2");
|
||
txtDifferenceCount.Text = (decimal.Parse(CuroverPlusCount) + SellCount - decimal.Parse(_DataTable.Rows[0]["overpluscount"].ToString())).ToString("F2");
|
||
txtCommodityBarCode.Text = _DataTable.Rows[0]["commodity_barcode"].ToString();
|
||
txtCommodityName.Text = _DataTable.Rows[0]["commodity_name"].ToString();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if (_List.Count() > 0)
|
||
{
|
||
DBHelper.ExecuteSqlTran(_List);
|
||
}
|
||
SearchDataView();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show("数据库连接失败,请重启收银机后重试!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
}
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
}
|
||
|
||
#endregion
|
||
private int GoodsExist(string BarCode, out string GoodsName, out decimal GoodsCount)
|
||
{
|
||
string _selectsql = "select 1 from t_checkcommodityex where check_state = 0 and " +
|
||
"serverpartshop_id = " + _serverpartshop_id;
|
||
try
|
||
{
|
||
if (DBHelper.QueryOdbc(_selectsql).Tables[0].Rows.Count == 0)
|
||
{
|
||
DialogResult _DialogResult = MessageBox.Show("未查询到盘点单,请先下载盘点单信息!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
if (_DialogResult == DialogResult.OK)
|
||
{
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
GoodsName = "";
|
||
GoodsCount = 0;
|
||
return 0;
|
||
}
|
||
else
|
||
{
|
||
GoodsName = "";
|
||
GoodsCount = 0;
|
||
return 0;
|
||
}
|
||
}
|
||
_selectsql = "select a.checkcommoditydetail_id, a.checkcommodity_id, a.serverpartstock_id, isnull(a.overpluscount,0) as overpluscount, " +
|
||
"a.checkdate, a.commodity_id, a.commodity_code, isnull(a.curoverpluscount,0) as curoverpluscount, a.commodity_barcode, " +
|
||
"a.checkdesc, a.commodity_name, a.commodity_salecount, isnull(a.commodity_totalcount,0) as commodity_totalcount, a.start_date, " +
|
||
"a.end_date, a.serverpart_id, a.lastoverpluscount, a.storage_count, a.out_count, a.sale_count " +
|
||
"from t_checkcommoditydetail a,t_checkcommodityex b " +
|
||
"where a.checkcommodity_id = b.checkcommodity_id and b.check_state = 0 and " +
|
||
"b.serverpartshop_id = " + _serverpartshop_id + " and a.commodity_barcode = '" + BarCode + "'";
|
||
DataTable _DataTable = DBHelper.QueryOdbc(_selectsql).Tables[0];
|
||
if (_DataTable.Rows.Count == 0)
|
||
{
|
||
//MessageBox.Show("该商品无库存信息", "系统提示", MessageBoxButtons.OK,
|
||
// MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
lblMessage.Text = "商品[" + BarCode + "]无库存信息";
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
GoodsName = "";
|
||
GoodsCount = 0;
|
||
return 1;
|
||
}
|
||
else
|
||
{
|
||
GoodsName = _DataTable.Rows[0]["commodity_name"].ToString();
|
||
decimal.TryParse(_DataTable.Rows[0]["overpluscount"].ToString(), out GoodsCount);
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
GoodsName = "";
|
||
GoodsCount = 0;
|
||
return 0;
|
||
}
|
||
return 9;
|
||
}
|
||
#region 盘点录入按键
|
||
/// <summary>
|
||
/// 盘点信息输入按键事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void CommodityInfo_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Enter)
|
||
{
|
||
string strBarCode, strCommodityNum, strInventoryDate;
|
||
if (cobCHECKMODE.Text == "请选择盘点模式")
|
||
{
|
||
//MessageBox.Show("请选择盘点模式!", "系统提示", MessageBoxButtons.OK,
|
||
// MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
lblMessage.Text = "请选择盘点模式!";
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
return;
|
||
}
|
||
if (CommodityInfo.Text != "")
|
||
{
|
||
txtCommodityName.Text = "";
|
||
string commodityInfo = CommodityInfo.Text;
|
||
string[] sArray = commodityInfo.Split(',');
|
||
strBarCode = sArray[0];
|
||
string goodsname;
|
||
decimal goodscount;
|
||
int _GoodCheck = GoodsExist(strBarCode, out goodsname, out goodscount);
|
||
switch (sArray.Count())
|
||
{
|
||
case 3:
|
||
strCommodityNum = sArray[1];
|
||
strInventoryDate = sArray[2];
|
||
if (_GoodCheck == 9)
|
||
{
|
||
CommodityInput(strBarCode, strCommodityNum, strInventoryDate, cobCHECKMODE.Text);
|
||
}
|
||
else if (_GoodCheck == 1)
|
||
{
|
||
CommodityInputUnmatch(strBarCode, strCommodityNum, strInventoryDate, cobCHECKMODE.Text);
|
||
}
|
||
break;
|
||
case 2:
|
||
strCommodityNum = sArray[1];
|
||
strInventoryDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||
if (_GoodCheck == 9)
|
||
{
|
||
CommodityInput(strBarCode, strCommodityNum, strInventoryDate, cobCHECKMODE.Text);
|
||
}
|
||
else if (_GoodCheck == 1)
|
||
{
|
||
CommodityInputUnmatch(strBarCode, strCommodityNum, strInventoryDate, cobCHECKMODE.Text);
|
||
}
|
||
break;
|
||
case 1:
|
||
if (_GoodCheck == 9)
|
||
{
|
||
CheckCommodityCount _CountMain = new CheckCommodityCount(goodsname, goodscount);
|
||
_CountMain.ShowDialog();
|
||
if (_CountMain.DialogResult == DialogResult.OK)
|
||
{
|
||
strCommodityNum = _CountMain.strValues;
|
||
strInventoryDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||
}
|
||
else
|
||
{
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
return;
|
||
}
|
||
CommodityInput(strBarCode, strCommodityNum, strInventoryDate, "重新盘点");
|
||
}
|
||
else if (_GoodCheck == 1)
|
||
{
|
||
CheckCommodityCount _CountMain = new CheckCommodityCount(strBarCode, goodscount);
|
||
_CountMain.ShowDialog();
|
||
if (_CountMain.DialogResult == DialogResult.OK)
|
||
{
|
||
strCommodityNum = _CountMain.strValues;
|
||
strInventoryDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||
}
|
||
else
|
||
{
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
return;
|
||
}
|
||
CommodityInputUnmatch(strBarCode, strCommodityNum, strInventoryDate, "重新盘点");
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//MessageBox.Show("请输入商品条码!", "系统提示", MessageBoxButtons.OK,
|
||
//MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
lblMessage.Text = "请输入商品条码!";
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region
|
||
/// <summary>
|
||
/// 下载按钮事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void Download_Click(object sender, EventArgs e)
|
||
{
|
||
List<string> _List = new List<string>();
|
||
Loading();
|
||
if (CheckDate != "")
|
||
{
|
||
if (MessageBox.Show("下载盘点单将会清空本地盘存数据,是否继续下载?", "系统提示", MessageBoxButtons.YesNo,
|
||
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
|
||
{
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
return;
|
||
}
|
||
}
|
||
ShowWaiteForm();
|
||
_WaitForm.ShowMessage("正在下载盘点初始数据......");
|
||
try
|
||
{
|
||
DBHelper.ExecuteSqlTran("delete from t_checkcommodityex");
|
||
DBHelper.ExecuteSqlTran("delete from t_checkcommoditydetail");
|
||
}
|
||
catch { }
|
||
DownLoadData();
|
||
_WaitForm.Close();
|
||
_WaitForm.Dispose();
|
||
#region
|
||
////下载并清空本地盘点数据
|
||
//string _selectsql = "SELECT CHECKCOMMODITY_ID, CHECKPERSON, CHECKDATE, SERVERPART_ID, SERVERPARTSHOP_ID, " +
|
||
// "CHECKCOMMODITY_DESC, CHECK_STATE, CHECK_PASSPORT_GUID, CHECK_TYPE " +
|
||
// "FROM " + _QualityHelper.dbname + ".T_CHECKCOMMODITYEX " +
|
||
// "WHERE CHECK_STATE = 0 AND SERVERPARTSHOP_ID = " + _QualityHelper.serverpartshop_id +
|
||
// " AND ROWNUM <= 1 ORDER BY CHECKCOMMODITY_ID DESC";
|
||
//OracleHelper _OracleHelper = new OracleHelper(_QualityHelper.dbip, _QualityHelper.dbport, _QualityHelper.conname, _QualityHelper.dbuser, _QualityHelper.dbpass);
|
||
//try
|
||
//{
|
||
// using (DataTable _DataTable = ConvertOraclTableToDoNetTable(_OracleHelper.ExcuteSqlGetDataSet(_selectsql, "T_CHECKCOMMODITYEX").Tables[0]))
|
||
// {
|
||
// if (_DataTable.Rows.Count > 0)
|
||
// {
|
||
// string _insertColumns = SqlColumns(_DataTable);
|
||
// string _insertValues = "";
|
||
// List<string> ValuesList = new List<string>();
|
||
// foreach (DataRow _Row in _DataTable.Rows)
|
||
// {
|
||
// ValuesList.Add(AnySqlValues(_DataTable, _Row));
|
||
// }
|
||
// for (int i = 0; i < ValuesList.Count(); i++)
|
||
// {
|
||
// _insertValues += (_insertValues == "" ? "(" + ValuesList[i] + ")" : ",(" + ValuesList[i] + ")");
|
||
// }
|
||
// _List.Add("INSERT INTO T_CHECKCOMMODITYEX (" + _insertColumns + ") VALUES " + _insertValues);
|
||
|
||
// _selectsql = "SELECT A.CHECKCOMMODITYDETAIL_ID, A.CHECKCOMMODITY_ID, A.SERVERPARTSTOCK_ID, " +
|
||
// "A.OVERPLUSCOUNT, A.CHECKDATE, A.COMMODITY_ID, A.COMMODITY_CODE, 0 as CUROVERPLUSCOUNT, " +
|
||
// "A.COMMODITY_BARCODE, A.CHECKDESC, A.COMMODITY_NAME, 0 as COMMODITY_SALECOUNT, " +
|
||
// "0 as COMMODITY_TOTALCOUNT, A.START_DATE, A.END_DATE, A.SERVERPART_ID, A.LASTOVERPLUSCOUNT, " +
|
||
// "A.STORAGE_COUNT, A.OUT_COUNT, A.SALE_COUNT FROM " + _QualityHelper.dbname +
|
||
// ".T_CHECKCOMMODITYDETAIL A," + _QualityHelper.dbname + ".T_CHECKCOMMODITYEX B " +
|
||
// "WHERE A.CHECKCOMMODITY_ID = B.CHECKCOMMODITY_ID AND B.CHECK_STATE = 0 AND B.SERVERPARTSHOP_ID = " +
|
||
// _QualityHelper.serverpartshop_id + " AND B.CHECKCOMMODITY_ID = " + _DataTable.Rows[0]["CHECKCOMMODITY_ID"].ToString();
|
||
// DataTable _DetailTable = ConvertOraclTableToDoNetTable(_OracleHelper.ExcuteSqlGetDataSet(_selectsql, "T_CHECKCOMMODITYDETAIL").Tables[0]);
|
||
// if (_DetailTable.Rows.Count > 0)
|
||
// {
|
||
// _insertColumns = SqlColumns(_DetailTable);
|
||
// _insertValues = "";
|
||
// ValuesList.Clear();
|
||
// foreach (DataRow _Row in _DetailTable.Rows)
|
||
// {
|
||
// ValuesList.Add(AnySqlValues(_DetailTable, _Row));
|
||
// }
|
||
// for (int i = 0; i < ValuesList.Count(); i++)
|
||
// {
|
||
// _insertValues += (_insertValues == "" ? "(" + ValuesList[i] + ")" : ",(" + ValuesList[i] + ")");
|
||
// }
|
||
// _List.Add("INSERT INTO T_CHECKCOMMODITYDETAIL (" + _insertColumns + ") VALUES " + _insertValues);
|
||
// }
|
||
// }
|
||
// else
|
||
// {
|
||
// _WaitForm.Close();
|
||
// _WaitForm.Dispose();
|
||
// MessageBox.Show("未查询到盘点单,请前往综管平台添加盘点单!", "系统提示", MessageBoxButtons.OK,
|
||
// MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
// CommodityInfo.Clear();
|
||
// CommodityInfo.Focus();
|
||
// CommodityInfo.SelectAll();
|
||
// return;
|
||
// }
|
||
// }
|
||
// if (_List.Count() > 0)
|
||
// {
|
||
// DBHelper.ExecuteSqlTran("delete from t_checkcommodityex where check_state <> 9");
|
||
// DBHelper.ExecuteSqlTran("delete from t_checkcommoditydetail a where not exists ( " +
|
||
// "select 1 from t_checkcommodityex b where a.checkcommodity_id = b.checkcommodity_id and b.check_state = 9)");
|
||
// DBHelper.ExecuteSqlTran(_List);
|
||
// }
|
||
// _WaitForm.Close();
|
||
// _WaitForm.Dispose();
|
||
// MessageBox.Show("盘点单下载成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
// Loading();
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
// _WaitForm.Close();
|
||
// _WaitForm.Dispose();
|
||
// DialogResult _DialogResult = MessageBox.Show("服务器连接失败,请检查网络状态!", "系统提示", MessageBoxButtons.OK,
|
||
// MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
// if (_DialogResult == DialogResult.OK)
|
||
// {
|
||
// return;
|
||
// }
|
||
//}
|
||
#endregion
|
||
}
|
||
#endregion
|
||
private void btnReset_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("重置后实盘信息将被清零,确定重置吗?", "系统提示", MessageBoxButtons.OKCancel,
|
||
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK)
|
||
{
|
||
string _updatesql = "update t_checkcommoditydetail set curoverpluscount = 0,commodity_salecount = 0,commodity_totalcount = 0,checkdesc = null ";
|
||
try
|
||
{
|
||
DBHelper.ExecuteSqlTran(_updatesql);
|
||
MessageBox.Show("盘点信息重置成功!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show("重置盘点信息失败,请重试!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
}
|
||
Loading();
|
||
}
|
||
}
|
||
|
||
#region 查看盘点记录
|
||
private void CheckView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
//if (CheckView.Rows.Count>0)
|
||
//{
|
||
// int _index = CheckView.CurrentRow.Index;
|
||
// txtCommodityBarCode.Text = CheckView.Rows[_index].Cells["commodity_barcode"].Value.ToString();
|
||
// txtCommodityName.Text = CheckView.Rows[_index].Cells["commodity_name"].Value.ToString();
|
||
// txtCommodityNum.Text = CheckView.Rows[_index].Cells["overpluscount"].Value.ToString();
|
||
// txtCheckCount.Text = CheckView.Rows[_index].Cells["curoverpluscount"].Value.ToString();
|
||
// txtDifferenceCount.Text = CheckView.Rows[_index].Cells["differencecount"].Value.ToString();
|
||
// txtInventoryDate.Text = CheckView.Rows[_index].Cells["checkdate"].Value.ToString();
|
||
// CommodityInfo.Focus();
|
||
// ChangeColor();
|
||
//}
|
||
}
|
||
#endregion
|
||
|
||
#region 盘差标记
|
||
public void ChangeColor()
|
||
{
|
||
for (int i = 0; i < CheckView.Rows.Count; i++)
|
||
{
|
||
if (decimal.Parse(CheckView.Rows[i].Cells["differencecount"].Value.ToString()) < 0)
|
||
{
|
||
for (int j = 0; j < CheckView.Rows[i].Cells.Count; j++)
|
||
{
|
||
CheckView.Rows[i].Cells[j].Style.ForeColor = Color.Red;
|
||
CheckView.Rows[i].Cells[j].Style.Font = new Font(CheckView.Font, FontStyle.Bold);
|
||
}
|
||
}
|
||
else if (decimal.Parse(CheckView.Rows[i].Cells["differencecount"].Value.ToString()) > 0)
|
||
{
|
||
for (int j = 0; j < CheckView.Rows[i].Cells.Count; j++)
|
||
{
|
||
CheckView.Rows[i].Cells[j].Style.ForeColor = Color.Green;
|
||
CheckView.Rows[i].Cells[j].Style.Font = new Font(CheckView.Font, FontStyle.Bold);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
for (int j = 0; j < CheckView.Rows[i].Cells.Count; j++)
|
||
{
|
||
CheckView.Rows[i].Cells[j].Style.ForeColor = SystemColors.ControlText;
|
||
CheckView.Rows[i].Cells[j].Style.Font = new Font(CheckView.Font, FontStyle.Regular);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 获取配置信息
|
||
/// <summary>
|
||
/// 获取配置信息
|
||
/// </summary>
|
||
/// <param name="ConfigUrationName">配置名称</param>
|
||
/// <param name="defaultValue">无配置信息时默认值</param>
|
||
/// <returns></returns>
|
||
private string ConfigUrationValues(string ConfigUrationName, string defaultValue)
|
||
{
|
||
string strSQL = "select configuration_name,configuration_values from dba.t_configuration where lower(configuration_name) = lcase('" + ConfigUrationName + "')";
|
||
string strValues = "";
|
||
using (DataTable _DataTable = DBHelper.QueryOdbc(strSQL).Tables[0])
|
||
{
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
foreach (DataRow row in _DataTable.Rows)
|
||
{
|
||
if (row["configuration_name"].ToString().ToLower() == ConfigUrationName.ToLower())
|
||
{
|
||
strValues = row["configuration_values"].ToString();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
strValues = ConfigHelper.Win32API.INIGetStringValue(Environment.CurrentDirectory + "\\setup.ini", "DBCONECT", ConfigUrationName, defaultValue);
|
||
if (strValues == "")
|
||
strValues = ConfigHelper.Win32API.INIGetStringValue(Environment.CurrentDirectory + "\\set.ini", "DBCONECT", ConfigUrationName, defaultValue);
|
||
}
|
||
}
|
||
return strValues;
|
||
}
|
||
#endregion
|
||
|
||
#region 转换DataTable字段类型
|
||
/// <summary>
|
||
/// 转换DataTable字段类型
|
||
/// </summary>
|
||
/// <param name="table"></param>
|
||
/// <returns></returns>
|
||
public static DataTable ConvertOraclTableToDoNetTable(DataTable table)
|
||
{
|
||
DataTable dt = new DataTable();
|
||
foreach (DataColumn dc in table.Columns)
|
||
{
|
||
DataColumn column = new DataColumn();
|
||
column.DataType = GetDataType(dc.DataType);
|
||
column.ColumnName = dc.ColumnName;
|
||
column.Caption = dc.Caption;
|
||
dt.Columns.Add(column);
|
||
}
|
||
dt.TableName = table.TableName;
|
||
dt.Merge(table, false, MissingSchemaAction.Ignore);
|
||
return dt;
|
||
}
|
||
/// <summary>
|
||
/// 字段类型
|
||
/// </summary>
|
||
/// <param name="dataType"></param>
|
||
/// <returns></returns>
|
||
public static Type GetDataType(Type dataType)
|
||
{
|
||
switch (dataType.ToString())
|
||
{
|
||
case "System.Double":
|
||
return System.Type.GetType("System.Decimal");
|
||
case "System.Int32":
|
||
return System.Type.GetType("System.Decimal");
|
||
case "System.Int16":
|
||
return System.Type.GetType("System.Decimal");
|
||
case "System.Int64":
|
||
return System.Type.GetType("System.Decimal");
|
||
default:
|
||
return dataType;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 构建SQL字段信息
|
||
/// <summary>
|
||
/// 获取列名
|
||
/// </summary>
|
||
/// <param name="Table"></param>
|
||
/// <returns></returns>
|
||
private string SqlColumns(DataTable Table)
|
||
{
|
||
string _Columnsstr = "";
|
||
foreach (DataColumn col in Table.Columns)
|
||
{
|
||
_Columnsstr += (_Columnsstr == "" ? col.ColumnName : "," + col.ColumnName);
|
||
}
|
||
return _Columnsstr;
|
||
}
|
||
/// <summary>
|
||
/// 获取行值(oracle)
|
||
/// </summary>
|
||
/// <param name="Table"></param>
|
||
/// <param name="Row"></param>
|
||
/// <returns></returns>
|
||
private string OraSqlValues(DataTable Table, DataRow Row)
|
||
{
|
||
string _valuesstr = "";
|
||
for (int i = 0; i < Table.Columns.Count; i++)
|
||
{
|
||
if (Table.Columns[i].DataType.ToString() == "System.Decimal")
|
||
{
|
||
_valuesstr += _valuesstr == "" ? (Row[i].ToString() == "" ? "NULL" : Row[i].ToString()) :
|
||
"," + (Row[i].ToString() == "" ? "NULL" : Row[i].ToString());
|
||
}
|
||
else if (Table.Columns[i].DataType.ToString() == "System.DateTime")
|
||
{
|
||
_valuesstr += _valuesstr == "" ? (Row[i].ToString() == "" ? "NULL" : "TO_DATE('" + Row[i].ToString() + "','YYYY/MM/DD HH24:MI:SS')") :
|
||
"," + (Row[i].ToString() == "" ? "NULL" : "TO_DATE('" + Row[i].ToString() + "','YYYY/MM/DD HH24:MI:SS')");
|
||
}
|
||
else
|
||
{
|
||
_valuesstr += _valuesstr == "" ? (Row[i].ToString() == "" ? "NULL" : "'" + Row[i].ToString()) + "'" :
|
||
"," + (Row[i].ToString() == "" ? "NULL" : "'" + Row[i].ToString() + "'");
|
||
}
|
||
}
|
||
return _valuesstr;
|
||
}
|
||
/// <summary>
|
||
/// 获取行值(anywhere)
|
||
/// </summary>
|
||
/// <param name="Table"></param>
|
||
/// <param name="Row"></param>
|
||
/// <returns></returns>
|
||
private string AnySqlValues(DataTable Table, DataRow Row)
|
||
{
|
||
string _valuesstr = "";
|
||
for (int i = 0; i < Table.Columns.Count; i++)
|
||
{
|
||
if (Table.Columns[i].DataType.ToString() == "System.Decimal")
|
||
{
|
||
_valuesstr += _valuesstr == "" ? (Row[i].ToString() == "" ? "NULL" : Row[i].ToString()) : "," +
|
||
(Row[i].ToString() == "" ? "NULL" : Row[i].ToString());
|
||
}
|
||
else if (Table.Columns[i].DataType.ToString() == "System.DateTime")
|
||
{
|
||
_valuesstr += _valuesstr == "" ? (Row[i].ToString() == "" ? "NULL" : "DATETIME('" + Row[i].ToString() + "')") :
|
||
"," + (Row[i].ToString() == "" ? "NULL" : "DATETIME('" + Row[i].ToString() + "')");
|
||
}
|
||
else
|
||
{
|
||
_valuesstr += _valuesstr == "" ? (Row[i].ToString() == "" ? "NULL" : "'" + Row[i].ToString()) + "'" :
|
||
"," + (Row[i].ToString() == "" ? "NULL" : "'" + Row[i].ToString() + "'");
|
||
}
|
||
}
|
||
return _valuesstr;
|
||
}
|
||
#endregion
|
||
|
||
private void btnCheck_Click(object sender, EventArgs e)
|
||
{
|
||
ShowWaiteForm();
|
||
_WaitForm.ShowMessage("正在校验盘点信息......");
|
||
string _updatesql = "UPDATE T_CHECKCOMMODITYDETAIL SET CUROVERPLUSCOUNT = D.CUROVERPLUSCOUNT," +
|
||
"COMMODITY_SALECOUNT = D.COMMODITY_SALECOUNT FROM T_CHECKCOMMODITYDETAIL C," +
|
||
"(SELECT A.COMMODITY_CODE AS COMMODITY_CODE,SUM(SELLCOUNT) AS CUROVERPLUSCOUNT," +
|
||
"SUM(SELLCOUNT) AS COMMODITY_SALECOUNT FROM T_SELLDATA A,T_CHECKCOMMODITYDETAIL B " +
|
||
"WHERE A.COMMODITY_CODE = B.COMMODITY_CODE AND B.CUROVERPLUSCOUNT <= 0 AND " +
|
||
"B.OVERPLUSCOUNT <> 0 AND A.SELLDATA_DATE BETWEEN DATETIME('" + CheckDate +
|
||
"') AND DATETIME('" + DateTime.Now.ToString() + "') GROUP BY A.COMMODITY_CODE) D " +
|
||
"WHERE C.COMMODITY_CODE = D.COMMODITY_CODE AND C.CHECKDATE = DATETIME('" + CheckDate + "')";
|
||
try
|
||
{
|
||
DBHelper.ExecuteSqlTran(_updatesql);
|
||
MessageBox.Show("盘点信息校验成功!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show("盘点信息校验失败,请重试!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
}
|
||
SearchDataView();
|
||
_WaitForm.Close();
|
||
_WaitForm.Dispose();
|
||
}
|
||
|
||
private void btnUpLoad_Click(object sender, EventArgs e)
|
||
{
|
||
if (MessageBox.Show("确认立即上传盘点结果吗?\n盘点上传后如需修改盘点结果,请到综管平台进行。", "系统提示",
|
||
MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.OK)
|
||
{
|
||
return;
|
||
}
|
||
List<string> _List = new List<string>();
|
||
string _selectsql = "select max(checkcommodity_id) from t_checkcommodityex " +
|
||
"where check_state = 0 and serverpartshop_id = " + _QualityHelper.serverpartshop_id;
|
||
try
|
||
{
|
||
ShowWaiteForm();
|
||
_WaitForm.ShowMessage("正在验证盘点结果,请稍候......");
|
||
string check_id = DBHelper.QueryOdbc(_selectsql).Tables[0].Rows[0][0].ToString();
|
||
_selectsql = "SELECT CHECKCOMMODITY_ID, CHECKPERSON, CHECKDATE, SERVERPART_ID, " +
|
||
"SERVERPARTSHOP_ID, CHECKCOMMODITY_DESC, CHECK_STATE, CHECK_PASSPORT_GUID, " +
|
||
"CHECK_TYPE FROM " + _QualityHelper.dbname + ".T_CHECKCOMMODITYEX " +
|
||
"WHERE SERVERPARTSHOP_ID = " + _QualityHelper.serverpartshop_id +
|
||
" AND CHECKCOMMODITY_ID = " + check_id;
|
||
OracleHelper _OracleHelper = new OracleHelper(_QualityHelper.dbip, _QualityHelper.dbport,
|
||
_QualityHelper.conname, _QualityHelper.dbuser, _QualityHelper.dbpass);
|
||
DataTable _OracleTable = _OracleHelper.ExcuteSqlGetDataSet(_selectsql).Tables[0];
|
||
if (_OracleTable.Rows.Count > 0)
|
||
{
|
||
if (_OracleTable.Rows[0]["CHECK_STATE"].ToString() == "9")
|
||
{
|
||
_WaitForm.Close();
|
||
_WaitForm.Dispose();
|
||
MessageBox.Show("当前盘点单数据已失效,请重新下载", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
|
||
CommodityInfo.Clear();
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
_selectsql = "SELECT CHECKCOMMODITY_ID, CHECKPERSON, CHECKDATE, SERVERPART_ID, SERVERPARTSHOP_ID, " +
|
||
"CHECKCOMMODITY_DESC, CHECK_STATE, CHECK_PASSPORT_GUID, CHECK_TYPE FROM T_CHECKCOMMODITYEX " +
|
||
"WHERE SERVERPARTSHOP_ID = " + _QualityHelper.serverpartshop_id + " AND CHECKCOMMODITY_ID = " + check_id;
|
||
DataTable _DataTable = DBHelper.QueryOdbc(_selectsql).Tables[0];
|
||
string _DBName = _QualityHelper.dbname;
|
||
for (int i = 0; i < _DataTable.Rows.Count; i++)
|
||
{
|
||
string _InsertSql = "INSERT INTO " + _DBName + ".T_CHECKCOMMODITYEX ( CHECKCOMMODITY_ID, CHECKPERSON, CHECKDATE, " +
|
||
"SERVERPART_ID, SERVERPARTSHOP_ID, CHECK_STATE, CHECK_TYPE ) VALUES ( " + _DataTable.Rows[i]["CHECKCOMMODITY_ID"].ToString() +
|
||
",'" + _DataTable.Rows[i]["CHECKPERSON"].ToString() + "',TO_DATE('" + _DataTable.Rows[i]["CHECKDATE"].ToString() + "','YYYY/MM/DD HH24:MI:SS')," +
|
||
_DataTable.Rows[i]["SERVERPART_ID"].ToString() + "," + _DataTable.Rows[i]["SERVERPARTSHOP_ID"].ToString() + ",TO_DATE('" +
|
||
_DataTable.Rows[i]["CHECK_STATE"].ToString() + "','YYYY/MM/DD HH24:MI:SS')," + _DataTable.Rows[i]["CHECK_TYPE"].ToString() + ")";
|
||
_WaitForm.ShowMessage("正在上传盘点单,请稍候......");
|
||
try
|
||
{
|
||
_OracleHelper.ExcuteSql(_InsertSql);
|
||
}
|
||
catch { }
|
||
}
|
||
}
|
||
_selectsql = "select a.checkcommoditydetail_id, a.checkcommodity_id, a.serverpartstock_id, a.overpluscount, " +
|
||
"a.checkdate, a.commodity_id, a.commodity_code, a.curoverpluscount, a.commodity_barcode, " +
|
||
"a.checkdesc, a.commodity_name, isnull(a.commodity_salecount,0) as commodity_salecount, " +
|
||
"isnull(a.commodity_totalcount,0) as commodity_totalcount, a.start_date, " +
|
||
"a.end_date, a.serverpart_id, a.lastoverpluscount, a.storage_count, a.out_count, a.sale_count " +
|
||
"from t_checkcommoditydetail a,t_checkcommodityex b " +
|
||
"where a.checkcommodity_id = b.checkcommodity_id and b.check_state = 0 " +
|
||
"and b.serverpartshop_id = " + _QualityHelper.serverpartshop_id +
|
||
" and b.checkcommodity_id = " + check_id;
|
||
using (DataTable _DataTable = DBHelper.QueryOdbc(_selectsql).Tables[0])
|
||
{
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
string _DBName = _QualityHelper.dbname;
|
||
_selectsql = "SELECT A.CHECKCOMMODITYDETAIL_ID, A.CHECKCOMMODITY_ID, A.SERVERPARTSTOCK_ID, " +
|
||
"A.OVERPLUSCOUNT, A.CHECKDATE, A.COMMODITY_ID, A.COMMODITY_CODE, A.CUROVERPLUSCOUNT, " +
|
||
"A.COMMODITY_BARCODE,A.CHECKDESC, A.COMMODITY_NAME, A.COMMODITY_SALECOUNT, " +
|
||
"A.COMMODITY_TOTALCOUNT, A.START_DATE,A.END_DATE, A.SERVERPART_ID, A.LASTOVERPLUSCOUNT, " +
|
||
"A.STORAGE_COUNT, A.OUT_COUNT, A.SALE_COUNT FROM " + _DBName + ".T_CHECKCOMMODITYDETAIL A," +
|
||
_DBName + ".T_CHECKCOMMODITYEX B " + "WHERE A.CHECKCOMMODITY_ID = B.CHECKCOMMODITY_ID AND " +
|
||
"B.SERVERPARTSHOP_ID = " + _QualityHelper.serverpartshop_id + " AND B.CHECKCOMMODITY_ID = " + check_id;
|
||
DataTable _DetailTable = _OracleHelper.ExcuteSqlGetDataSet(_selectsql).Tables[0];
|
||
string _updatesql = "UPDATE " + _DBName + ".T_CHECKCOMMODITYEX SET CHECK_STATE = 5 " +
|
||
"WHERE CHECKCOMMODITY_ID = " + check_id;
|
||
_List.Add(_updatesql);
|
||
int _Progress = 0;
|
||
foreach (DataRow _Row in _DataTable.Rows)
|
||
{
|
||
_Progress++;
|
||
_WaitForm.ShowMessage("正在验证盘点明细,请稍候......" + (int)((decimal)_Progress * 100 / _DataTable.Rows.Count) + "%");
|
||
if (_DetailTable.Select("CHECKCOMMODITYDETAIL_ID = " + _Row["checkcommoditydetail_id"].ToString()).Count() > 0)
|
||
{
|
||
_updatesql = "UPDATE " + _DBName + ".T_CHECKCOMMODITYDETAIL SET CUROVERPLUSCOUNT = " +
|
||
(_Row["curoverpluscount"].ToString() == "" ? "0" : _Row["curoverpluscount"].ToString()) + "," +
|
||
"COMMODITY_SALECOUNT = " + (_Row["commodity_salecount"].ToString() == "" ? "0" :
|
||
_Row["commodity_salecount"].ToString()) + ",COMMODITY_TOTALCOUNT = " +
|
||
(_Row["commodity_totalcount"].ToString() == "" ? "0" : _Row["commodity_totalcount"].ToString()) +
|
||
" WHERE COMMODITY_CODE = '" + _Row["commodity_code"].ToString() + "' AND CHECKCOMMODITY_ID = " +
|
||
_Row["checkcommodity_id"].ToString() + " AND CHECKCOMMODITYDETAIL_ID = " + _Row["checkcommoditydetail_id"].ToString();
|
||
_List.Add(_updatesql);
|
||
}
|
||
else
|
||
{
|
||
string _InsertSql = "INSERT INTO " + _DBName + ".T_CHECKCOMMODITYDETAIL (CHECKCOMMODITYDETAIL_ID," +
|
||
"CHECKCOMMODITY_ID,OVERPLUSCOUNT,CHECKDATE,COMMODITY_ID,COMMODITY_CODE,CUROVERPLUSCOUNT," +
|
||
"COMMODITY_BARCODE,COMMODITY_NAME,COMMODITY_SALECOUNT,COMMODITY_TOTALCOUNT,START_DATE," +
|
||
"END_DATE,SERVERPART_ID) VALUES ( " + _Row["CHECKCOMMODITYDETAIL_ID"].ToString() +
|
||
"," + _Row["CHECKCOMMODITY_ID"].ToString() + "," + _Row["OVERPLUSCOUNT"].ToString() +
|
||
",TO_DATE('" + _Row["CHECKDATE"].ToString() + "','YYYY/MM/DD HH24:MI:SS')," + _Row["COMMODITY_ID"].ToString() +
|
||
",'" + _Row["COMMODITY_CODE"].ToString() + "'," + _Row["CUROVERPLUSCOUNT"].ToString() +
|
||
",'" + _Row["COMMODITY_BARCODE"].ToString() + "','" + _Row["COMMODITY_NAME"].ToString() +
|
||
"'," + _Row["COMMODITY_SALECOUNT"].ToString() + "," + _Row["COMMODITY_TOTALCOUNT"].ToString() +
|
||
",TO_DATE('" + _Row["START_DATE"].ToString() + "','YYYY/MM/DD HH24:MI:SS'),TO_DATE('" +
|
||
_Row["END_DATE"].ToString() + "','YYYY/MM/DD HH24:MI:SS')," + _Row["SERVERPART_ID"].ToString() + ")";
|
||
_List.Add(_InsertSql);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (_List.Count() > 0)
|
||
{
|
||
_WaitForm.ShowMessage("正在上传盘点结果,请稍候......");
|
||
lblMessage.Text = "正在上传盘点数据,请稍候……";
|
||
_OracleHelper.ExecuteSqlTran(_List);
|
||
_WaitForm.Close();
|
||
_WaitForm.Dispose();
|
||
try
|
||
{
|
||
DBHelper.ExecuteSqlTran("update t_checkcommodityex set check_state = 5 where checkcommodity_id = " + check_id);
|
||
lblMessage.Text = "盘点单数据上传成功!";
|
||
MessageBox.Show("盘点单数据上传成功!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
}
|
||
catch (Exception ex)
|
||
{ }
|
||
}
|
||
else
|
||
{
|
||
_WaitForm.Close();
|
||
_WaitForm.Dispose();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
_WaitForm.Close();
|
||
_WaitForm.Dispose();
|
||
lblMessage.Text = "盘点单数据上传失败,请重试!";
|
||
MessageBox.Show("盘点单数据上传失败,请重试!", "系统提示", MessageBoxButtons.OK,
|
||
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
|
||
}
|
||
}
|
||
|
||
private void cobDifference_SelectionChangeCommitted(object sender, EventArgs e)
|
||
{
|
||
DataTable _DataTable = CheckView.DataSource as DataTable;
|
||
switch (cobDifference.Text)
|
||
{
|
||
case "损溢":
|
||
_DataTable.DefaultView.RowFilter = "differencecount <> 0";
|
||
break;
|
||
case "盘盈":
|
||
_DataTable.DefaultView.RowFilter = "differencecount > 0";
|
||
break;
|
||
case "盘亏":
|
||
_DataTable.DefaultView.RowFilter = "differencecount < 0";
|
||
break;
|
||
case "无差异":
|
||
_DataTable.DefaultView.RowFilter = "differencecount = 0";
|
||
break;
|
||
default:
|
||
_DataTable.DefaultView.RowFilter = "differencecount not is null";
|
||
break;
|
||
}
|
||
ChangeColor();
|
||
}
|
||
|
||
private void btnClose_Click(object sender, EventArgs e)
|
||
{
|
||
DialogResult _DialogResult = MessageBox.Show("即将退出进销存盘点,是否立即启动收银系统?", "系统提示",
|
||
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
|
||
if (_DialogResult == DialogResult.Cancel)
|
||
{
|
||
return;
|
||
}
|
||
if (_DialogResult == DialogResult.Yes)
|
||
{
|
||
string _StartAPP = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AutoUpdateEx.exe");
|
||
if (!File.Exists(_StartAPP))
|
||
{
|
||
_StartAPP = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
}
|
||
try
|
||
{
|
||
Process.Start(_StartAPP);
|
||
}
|
||
catch { }
|
||
}
|
||
Close();
|
||
}
|
||
|
||
private void CheckCommodity_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
switch (e.KeyCode)
|
||
{
|
||
case Keys.Escape:
|
||
DialogResult _DialogResult = MessageBox.Show("即将退出进销存盘点,是否立即启动收银系统?", "系统提示",
|
||
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||
if (_DialogResult == DialogResult.Cancel)
|
||
{
|
||
break;
|
||
}
|
||
if (_DialogResult == DialogResult.Yes)
|
||
{
|
||
string _StartAPP = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AutoUpdateEx.exe");
|
||
if (!File.Exists(_StartAPP))
|
||
{
|
||
_StartAPP = @"D:\HighWayPosSoft\AutoUpdateEx.exe";
|
||
}
|
||
try
|
||
{
|
||
Process.Start(_StartAPP);
|
||
}
|
||
catch { }
|
||
}
|
||
Environment.Exit(0);
|
||
break;
|
||
case Keys.F1:
|
||
txtCommodityBarCode.Enabled = false;
|
||
CommodityInfo.Focus();
|
||
CommodityInfo.SelectAll();
|
||
break;
|
||
case Keys.F2:
|
||
Download_Click(null, null);
|
||
break;
|
||
case Keys.F3:
|
||
btnCheck_Click(null, null);
|
||
break;
|
||
case Keys.F4:
|
||
btnUpLoad_Click(null, null);
|
||
break;
|
||
case Keys.F5:
|
||
btnReset_Click(null, null);
|
||
break;
|
||
case Keys.F6:
|
||
// txtCommodityBarCode.Enabled = false;
|
||
// CheckView.Focus();
|
||
CheckBillFail _NoInventory = new CheckBillFail(_serverpartshop_id, false);
|
||
_NoInventory.ShowDialog();
|
||
break;
|
||
//case Keys.F7:
|
||
// txtCheckCount.Focus();
|
||
// txtCheckCount.SelectAll();
|
||
// break;
|
||
case Keys.F8:
|
||
if (cobCHECKMODE.Text == "仓库盘点")
|
||
{
|
||
if (MessageBox.Show("确认完成仓库盘点进行门店盘点吗?", "系统提示", MessageBoxButtons.OKCancel,
|
||
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
|
||
{
|
||
lblHelp.Text = "直接输入条码并确认可修改盘点数量";
|
||
cobCHECKMODE.Text = "实时盘点";
|
||
lblCheckMode.Text = "门店盘点";
|
||
}
|
||
}
|
||
//else
|
||
//{
|
||
// cobCHECKMODE.Text = "仓库盘点";
|
||
// lblCheckMode.Text = "仓库盘点";
|
||
//}
|
||
break;
|
||
case Keys.F9:
|
||
CheckBillFail _CheckBillFail = new CheckBillFail(_serverpartshop_id, true);
|
||
_CheckBillFail.ShowDialog();
|
||
break;
|
||
}
|
||
}
|
||
|
||
private void CheckView_RowEnter(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
//if (CheckView.CurrentRow != null)
|
||
//{
|
||
// int _index = CheckView.CurrentRow.Index;
|
||
//txtCommodityName.Text = CheckView.Rows[e.RowIndex].Cells["commodity_name"].Value.ToString();
|
||
//txtCommodityNum.Text = CheckView.Rows[e.RowIndex].Cells["overpluscount"].Value.ToString();
|
||
//txtCheckCount.Text = CheckView.Rows[e.RowIndex].Cells["curoverpluscount"].Value.ToString();
|
||
//txtDifferenceCount.Text = CheckView.Rows[e.RowIndex].Cells["differencecount"].Value.ToString();
|
||
//txtInventoryDate.Text = CheckView.Rows[e.RowIndex].Cells["checkdate"].Value.ToString();
|
||
//if (!txtCommodityBarCode.Enabled)
|
||
//{
|
||
// txtCommodityBarCode.Text = CheckView.Rows[e.RowIndex].Cells["commodity_barcode"].Value.ToString();
|
||
// ChangeColor();
|
||
//}
|
||
//}
|
||
}
|
||
|
||
private void txtCheckCount_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Enter)
|
||
{
|
||
if (txtCheckCount.Text == "")
|
||
{
|
||
MessageBox.Show("请输入盘点数量", "系统提示", MessageBoxButtons.OK);
|
||
txtCheckCount.Focus();
|
||
txtCheckCount.SelectAll();
|
||
return;
|
||
}
|
||
decimal result;
|
||
if (decimal.TryParse(txtCheckCount.Text, out result))
|
||
{
|
||
CommodityInput(txtCommodityBarCode.Text, txtCheckCount.Text, DateTime.Now.ToString(), "重新盘点");
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("请输入正确的盘点数量", "系统提示", MessageBoxButtons.OK);
|
||
txtCheckCount.Focus();
|
||
txtCheckCount.SelectAll();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void CheckCommodity_Shown(object sender, EventArgs e)
|
||
{
|
||
ShowWaiteForm();
|
||
_WaitForm.ShowMessage("正在验证日结信息......");
|
||
APPLoading();
|
||
_WaitForm.Close();
|
||
_WaitForm.Dispose();
|
||
}
|
||
|
||
private void btnMin_Click(object sender, EventArgs e)
|
||
{
|
||
WindowState = FormWindowState.Minimized;
|
||
}
|
||
|
||
private void txtSearch_TextChanged(object sender, EventArgs e)
|
||
{
|
||
if (txtSearch.Text != "")
|
||
{
|
||
DataTable _DataTable = CheckView.DataSource as DataTable;
|
||
_DataTable.DefaultView.RowFilter = "commodity_barcode like '%" + txtSearch.Text +
|
||
"%' or commodity_name like '%" + txtSearch.Text + "%'";
|
||
}
|
||
else
|
||
{
|
||
cobDifference_SelectionChangeCommitted(null, null);
|
||
}
|
||
}
|
||
|
||
private void btnFail_Click(object sender, EventArgs e)
|
||
{
|
||
CheckBillFail _CheckBillFail = new CheckBillFail(_serverpartshop_id, true);
|
||
_CheckBillFail.ShowDialog();
|
||
}
|
||
|
||
private void btnNoInventory_Click(object sender, EventArgs e)
|
||
{
|
||
CheckBillFail _NoInventory = new CheckBillFail(_serverpartshop_id, false);
|
||
_NoInventory.ShowDialog();
|
||
}
|
||
}
|
||
}
|