ldj/wince/bak/DeiNiuWmsWINCE - 副本/forms/StorageLocationCheck.cs

350 lines
10 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections.Specialized;
using System.Data;
using DeiNiu.Wms.CE.Util;
namespace DeiNiu.Wms.CE
{
public partial class StorageLocationCheck : basicForm
{
#region
string gooodsid = string.Empty;
string batch = string.Empty;
int skuId = 0;
decimal oldcount=0m;
DataTable dtaa = null;
// StockLocationServiceClient client { get; set; }
public StorageLocationCheck()
{
setTitle();
InitializeComponent();
initialComBoxes();
lacationid_txt.Focus();
button1.Enabled = false;
button2.Enabled = false;
// client = new StockLocationServiceClient(WcfHelp.getBasicBinding(), WcfHelp.getEndpoint("StockLocationService"));
//client.setOperId(LoginInfo.UserId, LoginInfo.Token);
}
private void BarCodeStorage_Load(object sender, EventArgs e)
{
//if (page == 0)
//{
// goodscode_txt.Enabled = true;
// cb1.Checked = false;
// cb1.Enabled = true;
//}
//else
//{
// lacationid_txt.Focus();
// goodscode_txt.Enabled = false;
// cb1.Checked = true;
// cb1.Enabled = false;
//}
}
#endregion
/// <summary>
/// 扫描商品条码,获取数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <summary>
/// 绑定数据到界面
/// </summary>
/// <param name="index0"></param>
/// <param name="GetData"></param>
private void SetValue( DataTable dta)
{
skuId = Convert.ToInt16(dta.Rows[0]["skuId"].ToString());
gooodsid = dta.Rows[0]["goodsId"].ToString();//商品id
name_lab.Text = dta.Rows[0]["goodsName"].ToString();//品名
spec_lab.Text = dta.Rows[0]["spec"].ToString();//规格
PCompany_lab.Text = dta.Rows[0]["manufacturer"].ToString();//生产厂商
batch = dta.Rows[0]["batch"].ToString();
batch_lab.Text = batch;//批号
product_date_lab.Text = dta.Rows[0]["productDate"].ToString();//生产日期
save_date_lab.Text = dta.Rows[0]["validDate"].ToString();//有效期
//oldcount_lab.Text = GetData[y].Val;//库存数量
string count = dta.Rows[0]["count"].ToString();
count_txt.Text = count;
oldcount = Convert.ToDecimal(count);
Stocknum_lab.Text = count;
lbbigcount.Text = dta.Rows[0]["bigcount"].ToString();
unit_lab.Text = dta.Rows[0]["unit"].ToString();//单位
lacationid_txt.Visible = true;
}
/// <summary>
/// 扫描货位码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lacationid_txt_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
dtaa = null;
string locId = lacationid_txt.Text;
lacationid_txt.Text = "";
lacationid_lab.Text = locId;
if (locId.Length < 7)
{
MessageBox.Show("请扫货位条码");
lacationid_txt.Focus();
return;
}
#region
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
DataTable dt;
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
try
{
dt = client.getStockLocation(locId);
}
catch (Exception er)
{
Cursor.Current = System.Windows.Forms.Cursors.Default;
MessageBox.Show("发生错误:" + er.Message);
return;
}
Cursor.Current = System.Windows.Forms.Cursors.Default;
if (dt.Rows.Count > 0)
{
SetValue(dt);
dtaa = dt;
button1.Enabled = true;
button2.Enabled = true;
}
else
{
//MessageBox.Show("无数据");
lacationid_lab.Text = string.Format("'{0}' 无相关库存信息", locId);
button1.Enabled=false;
button2.Enabled = false;
name_lab.Text = spec_lab.Text = PCompany_lab.Text = unit_lab.Text = "";
Stocknum_lab.Text = batch_lab.Text = row_lab.Text = product_date_lab.Text = save_date_lab.Text = "";
count_txt.Text = "0";
lacationid_txt.Focus();
}
#endregion
Cursor.Current = System.Windows.Forms.Cursors.Default;
}
}
private void cb1_CheckStateChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)//修改数量
{
try
{
string locID = lacationid_lab.Text.ToString();
decimal count = 0m;
try
{
count = Convert.ToDecimal(count_txt.Text.ToString());
}
catch
{
MessageBox.Show("请输入数量!");
count_txt.Focus();
return;
}
if (oldcount == count)
{
MessageBox.Show("请确认输入的数量");
count_txt.Focus();
return;
}
if (this.comboBox1.SelectedIndex ==0)
{
MessageBox.Show("请选择原因!");
comboBox1.Focus();
return;
}
bool i;
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
try
{
i = client.updateStockLocation(locID, gooodsid, skuId, batch, count, comboBox1.Text.ToString(), (int)enumStockRecordType., LoginInfo.UserId, LoginInfo.Token);
}
catch (Exception er)
{
Cursor.Current = System.Windows.Forms.Cursors.Default;
MessageBox.Show("发生错误:" + er.Message);
return;
}
Cursor.Current = System.Windows.Forms.Cursors.Default;
if (i == false)
{
MessageBox.Show("修改失败!!!");
lacationid_txt.Focus();
}
else
{
MessageBox.Show("修改成功!");
//Stocknum_lab.Text ="库存:" +sl;
dtaa = null;
name_lab.Text = spec_lab.Text = PCompany_lab.Text = lacationid_lab.Text = unit_lab.Text = lbbigcount.Text = "";
Stocknum_lab.Text = batch_lab.Text = row_lab.Text = product_date_lab.Text = save_date_lab.Text = "";
count_txt.Text = "0";
lacationid_txt.Focus();
}
}
catch(Exception er)
{
MessageBox.Show("出错了:" +er.Message);
lacationid_txt.Focus();
}
}
private void button2_Click(object sender, EventArgs e)//货位清零
{
if (this.comboBox1.SelectedIndex == 0)
{
MessageBox.Show("请选择原因!");
comboBox1.Focus();
return;
}
Message me = new Message();
me.title = "您确认要清空货位吗?";
if(me.ShowDialog()==DialogResult.Cancel)
{
lacationid_txt.Focus();
return;
}
me.title = "真的要清空吗?";
if (me.ShowDialog() == DialogResult.Cancel)
{
lacationid_txt.Focus();
return;
}
me.title = "请再次确认是否要清空货位?";
if (me.ShowDialog() == DialogResult.Cancel)
{
lacationid_txt.Focus();
return;
}
string locId = lacationid_lab.Text.ToString();
bool tr ;
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
try
{
tr = client.clearLocation(locId, comboBox1.Text, LoginInfo.UserId, LoginInfo.Token);
}
catch (Exception er)
{
Cursor.Current = System.Windows.Forms.Cursors.Default;
MessageBox.Show("发生错误:" + er.Message);
return;
}
Cursor.Current = System.Windows.Forms.Cursors.Default;
if(tr==true)
{
MessageBox.Show("货位清空成功!");
dtaa = null;
name_lab.Text = spec_lab.Text = PCompany_lab.Text = lacationid_lab.Text = unit_lab.Text = "";
Stocknum_lab.Text = batch_lab.Text = row_lab.Text = product_date_lab.Text = save_date_lab.Text = "";
count_txt.Text = "0";
lacationid_txt.Focus();
}
else
{ MessageBox.Show("货位清空失败!!!!");
lacationid_txt.Focus();
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void lacationid_txt_TextChanged(object sender, EventArgs e)
{
}
private void lacationid_txt_LostFocus(object sender, EventArgs e)
{
}
private void initialComBoxes()
{
Utils.buildCombox(2008, this.comboBox1);
}
}
}