153 lines
6.9 KiB
C#
153 lines
6.9 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
|
||
namespace InvoicingTool
|
||
{
|
||
public partial class CommodityChoice : Form
|
||
{
|
||
#region 属性
|
||
public string ReceiveCode { get; set; }
|
||
public string DeliverCount { get; set; }
|
||
public string receivecenter_code { get; set; }
|
||
public string T_RECEIVEDETAILSERVERPART = "T_RECEIVEDETAILSERVERPART";
|
||
public string T_SERVERPARTSTOCK = "T_SERVERPARTSTOCK";
|
||
QualityHelper quality = new QualityHelper();
|
||
#endregion
|
||
|
||
public CommodityChoice(string id)
|
||
{
|
||
InitializeComponent();
|
||
Load();
|
||
receivecenter_code = id;
|
||
}
|
||
|
||
string sql =
|
||
@"select
|
||
1 as id,commodityex_id,commodity_barcode,commodity_code,commodity_name,commodity_rule,commodity_retailprice
|
||
from t_commodityex";
|
||
|
||
#region 方法-->绑定数据
|
||
private void Load()
|
||
{
|
||
try
|
||
{
|
||
//页面加载时绑定数据
|
||
DataTable commodity = DBHelper.QueryOdbc(sql).Tables[0];
|
||
if (commodity.Rows.Count > 0)
|
||
{
|
||
for (int i = 0; i < commodity.Rows.Count; i++)
|
||
{
|
||
commodity.Rows[i]["id"] = i + 1;
|
||
}
|
||
CommodityData.DataSource = commodity;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 页面关闭事件
|
||
private void btnClose_Click(object sender, EventArgs e)
|
||
{
|
||
//页面关闭时自动刷新主页面数据
|
||
this.DialogResult = DialogResult.OK;
|
||
Close();
|
||
}
|
||
#endregion
|
||
|
||
#region 方法-->文本框模糊查询事件
|
||
private void txtbarcode_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode != Keys.Enter)
|
||
{
|
||
DataTable _DataTable = CommodityData.DataSource as DataTable;
|
||
_DataTable.DefaultView.RowFilter =
|
||
"commodity_barcode like '%" + txtbarcode.Text + "%' or commodity_name like '%" + txtbarcode.Text + "%'";
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法-->绑定选择列单机事件
|
||
private void CommodityData_CellClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
List<string> _List = new List<string>();
|
||
if (CommodityData.Columns[e.ColumnIndex].Name == "Choice")
|
||
{
|
||
string barcode = CommodityData.Rows[e.RowIndex].Cells["commodity_barcode"].Value.ToString();
|
||
string commodity_id = CommodityData.Rows[e.RowIndex].Cells["commodityex_id"].Value.ToString();
|
||
string commodity_code = CommodityData.Rows[e.RowIndex].Cells["commodity_code"].Value.ToString();
|
||
string commodity_name = CommodityData.Rows[e.RowIndex].Cells["commodity_name"].Value.ToString();
|
||
string commodity_rule = CommodityData.Rows[e.RowIndex].Cells["commodity_rule"].Value.ToString();
|
||
string sqls = "select receiveserverpart_id from t_receiveserverpart_ex where receivecenter_code=" + receivecenter_code;
|
||
string receiveserverpart_id = "";
|
||
try
|
||
{
|
||
DataTable getreceiveserverpart_id = DBHelper.QueryOdbc(sqls).Tables[0];
|
||
receiveserverpart_id = getreceiveserverpart_id.Rows[0][0].ToString();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
InvoicingCommodityCount _CountMain = new InvoicingCommodityCount();
|
||
_CountMain.ShowDialog();
|
||
if (_CountMain.DialogResult == DialogResult.OK)
|
||
{
|
||
DeliverCount = _CountMain.strValues;
|
||
}
|
||
string _select = "select a.receivedetailserverpart_id,a.receiveserverpart_id, a.commodity_name,a.commodity_code, a.commodity_barcode, a.delivercount " +
|
||
"from t_receivedetailserverpart_ex a,t_receiveserverpart_ex b where b.receivecenter_code = '" + receivecenter_code + "' and a.commodity_barcode = '" +
|
||
barcode + "' and a.receiveserverpart_id = b.receiveserverpart_id";
|
||
DataTable _ReceiveDetailServerPart = DBHelper.QueryOdbc(_select).Tables[0];
|
||
if (_ReceiveDetailServerPart.Rows.Count > 0)
|
||
{
|
||
//if (MessageBox.Show("商品条码:" + barcode + "\r已录入单据,是否叠加数量?\r是:叠加 否:覆盖", "",
|
||
// MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
|
||
//{
|
||
string _update = "update t_receivedetailserverpart_ex set delivercount = delivercount+" + DeliverCount +
|
||
" where receiveserverpart_id = " + _ReceiveDetailServerPart.Rows[0]["receiveserverpart_id"];
|
||
_List.Add(_update);
|
||
//}
|
||
//else
|
||
//{
|
||
// string _update = "update t_receivedetailserverpart_ex set delivercount = " + DeliverCount +
|
||
// " where receiveserverpart_id = " + _ReceiveDetailServerPart.Rows[0]["receiveserverpart_id"];
|
||
// _List.Add(_update);
|
||
//}
|
||
}
|
||
else
|
||
{
|
||
decimal _MaxID = 0;
|
||
try
|
||
{
|
||
_MaxID = decimal.Parse(DBHelper.QueryOdbc("select max(receivedetailserverpart_id) from t_receivedetailserverpart_ex").Tables[0].Rows[0][0].ToString());
|
||
}
|
||
catch
|
||
{
|
||
_MaxID = 0;
|
||
}
|
||
string _insert =
|
||
@"insert into t_receivedetailserverpart_ex (receivedetailserverpart_id, receiveserverpart_id, commodity_name,commodity_id,
|
||
commodity_code, commodity_barcode, unit, unitcount, delivercount,cenreceivedetail_desc,commodity_rule)
|
||
values (" + (_MaxID + 1) + "," + receiveserverpart_id + ",'" + commodity_name + "','" + commodity_id + "','" + commodity_code
|
||
+ "','" + barcode + "',1,1," + DeliverCount + ",'" + receivecenter_code + "','"+commodity_rule+"')";
|
||
_List.Add(_insert);
|
||
}
|
||
if (_List.Count() > 0)
|
||
{
|
||
DBHelper.ExecuteSqlTran(_List);
|
||
MessageBox.Show("选择成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|