ab56a9bcf7
SVN-Revision: r240
546 lines
22 KiB
C#
546 lines
22 KiB
C#
/***********************
|
|
* 说明:单据条码输入
|
|
* 创建人:龚宇超
|
|
* 创建日期:
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
***********************/
|
|
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;
|
|
using Lskj.Control;
|
|
using Lskj.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Util;
|
|
using Lskj.Data;
|
|
using Lskj.Business.Impl;
|
|
using DevExpress.XtraGrid.Views.Base;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using Lskj.Business;
|
|
|
|
namespace Lskj.PubBillDetail
|
|
{
|
|
/// <summary>
|
|
/// Class FrmInputBarCode.
|
|
/// </summary>
|
|
public partial class FrmInputBarCode : BaseForm
|
|
{
|
|
|
|
#region 公有属性
|
|
/// <summary>
|
|
/// 模块对象
|
|
/// </summary>
|
|
public DynamicBillInputBarModel SysModel;
|
|
/// <summary>
|
|
/// 单据明细模型
|
|
/// </summary>
|
|
public BillDetailModel BillDetailModel;
|
|
/// <summary>
|
|
/// 单据条码录入
|
|
/// </summary>
|
|
public BillBarCodeModel BillBarCodeModel;
|
|
/// <summary>
|
|
/// 模块名称
|
|
/// </summary>
|
|
public string _fromText;
|
|
#endregion
|
|
|
|
#region 私有属性
|
|
/// <summary>
|
|
/// 列前缀
|
|
/// </summary>
|
|
private string _columnPrefix;
|
|
|
|
/// <summary>
|
|
/// 打印sql2
|
|
/// </summary>
|
|
private string _printSql2 = "";
|
|
#endregion
|
|
public FrmInputBarCode()
|
|
: this("")
|
|
{
|
|
|
|
}
|
|
public FrmInputBarCode(string Fromtext)
|
|
{
|
|
InitializeComponent();
|
|
this._fromText = Fromtext;
|
|
}
|
|
|
|
#region 初始化设置
|
|
/// <summary>
|
|
/// <para>说明:初始化设置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeSetting()
|
|
{
|
|
this.Text = this.SysModel.FormText + "单据号" + this.SysModel.BilldocumentId;
|
|
DataTable dt = BillImpl.GetBillDetail(this.SysModel.ParentDLLCoid);
|
|
if (dt.Rows.Count == 0)
|
|
{
|
|
MessageUtil.Show(string.Format(ResourceKeys.ParameterError, this.SysModel.ParentDLLCoid));
|
|
return;
|
|
}
|
|
this.BillDetailModel = new BillDetailModel(dt.Rows[0]);
|
|
//获取列前缀
|
|
this._columnPrefix = BaseImpl.GetColumnPrefix(this.BillDetailModel.DetailTable);
|
|
DataTable dtTmp = BillImpl.GetBillDeatilInfo(this.BillDetailModel.DetailTable, this._columnPrefix, this.SysModel.BilldocumentId, this.SysModel.DetailId);
|
|
if (dtTmp.Rows.Count < 1)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFindBarCodeInfo);
|
|
return;
|
|
}
|
|
dtTmp = BillImpl.GetProductInfo(this.SysModel.ProductId);
|
|
//获取商品信息
|
|
this.BillBarCodeModel = new BillBarCodeModel(dtTmp.Rows[0]);
|
|
this.lbProductBrand.Text = this.BillBarCodeModel.ProductBrand;
|
|
this.lbProductColor.Text = this.BillBarCodeModel.Color;
|
|
this.lbProductId.Text = this.SysModel.ProductId;
|
|
this.lbProductModel.Text = this.BillBarCodeModel.ProductModel;
|
|
this.lbProductName.Text = this.BillBarCodeModel.ProductName;
|
|
this.lbProductSpec.Text = this.BillBarCodeModel.ProductSpec;
|
|
this.lbProductType.Text = this.BillBarCodeModel.ProductClassify;
|
|
this.gridBarCode.SetReadOnlyColumns(BillImpl.SetProductBarCodeColumns());
|
|
//绑定条码表格数据
|
|
this.gridBarCode.SetGridViewDataSource(BillImpl.GetProductBarCodeData(this.SysModel.ParentDLLCoid, this.SysModel.BilldocumentId, this.SysModel.DetailId));
|
|
this.lbTip.Text = string.Format(ResourceKeys.BarCodeHintMsg, this.SysModel.CodeCount, this.gridBarCode.DataRowCount());
|
|
this.gridBarCode.GridView.KeyDown += new KeyEventHandler(gridBarCode_KeyDown);
|
|
this.txt_input.TextEdit.KeyDown += new KeyEventHandler(txt_input_KeyDown);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:窗体加载时</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
SysModel.Privilege = SysModel.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(SysModel.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(SysModel.ModuleCode) + "";
|
|
if (!this.SysModel.HasPrivilege())
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnPurview);
|
|
this.Close();
|
|
}
|
|
this.InitializeSetting();
|
|
this.InitializeControl();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化控件
|
|
/// <summary>
|
|
/// <para>说明:初始化控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeControl()
|
|
{
|
|
if (!this.SysModel.IsView)
|
|
{
|
|
this.btnAdd.Enabled = false;
|
|
this.btnDelete.Enabled = false;
|
|
this.btnImport.Enabled = false;
|
|
this.txt_input.Visible = false;
|
|
this.txt_Count.Visible = false;
|
|
}
|
|
if (!this.SysModel.IsView || this.SysModel.IsEdit)
|
|
{
|
|
this.btnSave.Enabled = false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 录入条码
|
|
/// <summary>
|
|
/// <para>说明:录入条码</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private bool AddUniqueCode(string uCode, string uAmount, string uGroup, string uJyBillNo)
|
|
{
|
|
if (string.IsNullOrEmpty(uCode)) return false;
|
|
if (this.SysModel.CodeCount <= this.gridBarCode.GridView.DataRowCount)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.InputCountGTR);
|
|
return false;
|
|
}
|
|
int uniqueCode = this.gridBarCode.GridView.LocateByValue("uniqueCode", uCode, null);
|
|
if (uniqueCode < 0)
|
|
{
|
|
string runNumber = BillImpl.GetBillNo("'FIXED'");
|
|
if (string.IsNullOrWhiteSpace(runNumber))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.CreateSerialNumberFail);
|
|
return false;
|
|
}
|
|
|
|
//验证
|
|
int result = BillImpl.InsertProductBarCodeData(this.SysModel.ModuleCode, this.SysModel.ParentDLLCoid, this.SysModel.BilldocumentId, this.SysModel.DetailId, uCode, this.SysModel.ProductId, runNumber, uAmount, uGroup, uJyBillNo);
|
|
if (result < 1)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault);
|
|
return false;
|
|
}
|
|
this.lbTip.Text = string.Format(ResourceKeys.BarCodeHintMsg, this.SysModel.CodeCount, this.gridBarCode.GridView.DataRowCount);
|
|
this.gridBarCode.SetGridViewDataSource(BillImpl.GetProductBarCodeData(this.SysModel.ParentDLLCoid, this.SysModel.BilldocumentId, this.SysModel.DetailId));
|
|
}
|
|
this.gridBarCode.GridView.ClearSelection();
|
|
this.gridBarCode.GridView.SelectRow(uniqueCode);
|
|
return true;
|
|
}
|
|
#endregion
|
|
#region 事件相关
|
|
/// <summary>
|
|
/// <para>说明:导入</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnInput_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//导入窗口
|
|
FrmImportBarCode form = new FrmImportBarCode();
|
|
form.AddBaeCodeEvent += new FrmImportBarCode.AddBarCodeEventHandler(AddUniqueCode);
|
|
form.ShowDialog();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("导入事件出错!", ex);
|
|
//MessageUtil.Show("导入事件出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:导出</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnExport_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.gridBarCode.GridControl.ToExcel(this._fromText);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:浏览</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnView_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string printPath = PubUtil.PrintFileAbsolutelyPath;
|
|
string billModuleFile = "barcodePreview1.rmf";
|
|
string tmpSql = string.Format("select '{0}' as Billdocument_Id,'{1}' as model,'{2}' as ProductId,'{3}' as pl,'{4}' as pp,'{5}' as gg,'{6}' as ys", this.SysModel.BilldocumentId, this.lbProductModel.Text, this.SysModel.ProductId, this.lbProductType.Text, this.lbProductBrand.Text, this.lbProductSpec.Text, this.lbProductColor.Text);
|
|
string tmpSql1 = string.Format("select * from wms_productBarcode where modid='{0}' and primaryKey='{1}' and mxid='{2}'", this.SysModel.ParentDLLCoid, this.SysModel.BilldocumentId, this.SysModel.DetailId);
|
|
DelphiHelper.LoadDelphiDll(printPath, printPath, billModuleFile, tmpSql, tmpSql1, 1, "");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:条码输入框按键事件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void txt_input_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (!this.SysModel.IsView) return;
|
|
if (e.KeyCode == Keys.Return)
|
|
{
|
|
string code = this.txt_input.EditText.Trim();
|
|
string[] codeSplit = code.Split('&');
|
|
if (codeSplit.Length > 1)
|
|
{
|
|
this.txt_Count.Text = codeSplit[1];
|
|
}
|
|
AddUniqueCode(codeSplit[0], this.txt_Count.EditText.Trim(), "", "");
|
|
this.txt_input.EditText = "";
|
|
txt_Count.Text = "1";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:条码表格按键事件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void gridBarCode_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//ctrl+c复制
|
|
if (e.Control & e.KeyCode == Keys.C)
|
|
{
|
|
object obj = this.gridBarCode.GridView.GetFocusedRowCellValue(this.gridBarCode.GridView.FocusedColumn);
|
|
if (obj != null)
|
|
{
|
|
Clipboard.SetDataObject(obj);
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
if (e.KeyCode == Keys.F6 || e.KeyCode == Keys.F7)
|
|
{
|
|
GridColumn gc = this.gridBarCode.GridView.FocusedColumn;
|
|
if (gc != null && this.gridBarCode.GridView.RowCount > 0 && gc.OptionsColumn.AllowEdit == true && this.gridBarCode.GridView.OptionsBehavior.Editable == true)
|
|
{
|
|
GridCell[] selecells = this.gridBarCode.GridView.GetSelectedCells();
|
|
if (selecells.Length == 1)
|
|
{
|
|
if (gridBarCode.GridView.FocusedRowHandle < gridBarCode.GridView.RowCount)
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.IsChangeCurrentCellData, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
|
|
object obj = this.gridBarCode.GridView.GetFocusedRowCellValue(gc);
|
|
if (obj != null)
|
|
{
|
|
int focusedRowHandle = this.gridBarCode.GridView.FocusedRowHandle;
|
|
for (int i = focusedRowHandle; i < this.gridBarCode.GridView.RowCount; i++)
|
|
{
|
|
this.gridBarCode.GridView.FocusedRowHandle = i;
|
|
object obj1 = this.gridBarCode.GridView.GetRowCellValue(i, gc);
|
|
if (e.KeyCode == Keys.F6)
|
|
{
|
|
if ((obj1 == null) || (obj1.ToString() == "0") || (obj1.ToString() == ""))
|
|
this.gridBarCode.GridView.SetRowCellValue(i, gc, obj);
|
|
}
|
|
else
|
|
this.gridBarCode.GridView.SetRowCellValue(i, gc, obj);
|
|
this.gridBarCode.GridView.PostEditor();
|
|
}
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:保存</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.gridBarCode.GridView.CloseEditor();
|
|
this.gridBarCode.GridView.UpdateCurrentRow();
|
|
//更新数据
|
|
DataTable table = this.gridBarCode.GridControl.DataSourceTable();
|
|
|
|
if (table.Rows.Count > 0 && table.Rows.Cast<DataRow>().FirstOrDefault(x => x.RowState == DataRowState.Modified) != null)
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.IsSaveApplyData, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
WaitForm.ShowForm(ResourceKeys.Handing);
|
|
BillImpl.UpdateProductBarCodeData(table);
|
|
//调用存储过程进行保存验证
|
|
BaseSaveModel saveModel = new BaseSaveModel
|
|
{
|
|
BaseSaveType = SaveType.Update,
|
|
BaseSql = "select 1",
|
|
KeyField = "",
|
|
FieldValue = this.SysModel.DetailId,
|
|
MenuCode = this.SysModel.ParentDLLCoid,
|
|
TableName = ""
|
|
};
|
|
int result = BaseModuleImpl.SaveBasePanelData(saveModel);
|
|
if (result == 1)
|
|
{
|
|
this.gridBarCode.SetGridViewDataSource(BillImpl.GetProductBarCodeData(this.SysModel.ParentDLLCoid, this.SysModel.BilldocumentId, this.SysModel.DetailId));
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(saveModel.FaultMsg);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnUpdateData);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex.Message.Contains("ix") ? ResourceKeys.InputRepeatData : ex.Message);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:删除</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnDelete_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int[] selectRows = this.gridBarCode.GridView.GetSelectedRows();
|
|
if (selectRows.Length > 0)
|
|
{
|
|
if (MessageUtil.Show(string.Format(ResourceKeys.DeleteRows, selectRows.Length), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
|
|
{
|
|
WaitForm.ShowForm(ResourceKeys.Handing);
|
|
|
|
foreach (int row in selectRows)
|
|
{
|
|
DataRow dr = this.gridBarCode.GridView.GetDataRow(row);
|
|
int result = BillImpl.DeleteProductBarCodeData(this.SysModel.ModuleCode, this.SysModel.BilldocumentId, this.SysModel.DetailId, dr);
|
|
if (result < 1)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault);
|
|
return;
|
|
}
|
|
}
|
|
this.gridBarCode.GridView.DeleteSelectedRows();
|
|
this.lbTip.Text = string.Format(ResourceKeys.BarCodeHintMsg, this.SysModel.CodeCount, this.gridBarCode.GridView.DataRowCount);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:添加</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm(ResourceKeys.DataSaving);
|
|
this.AddUniqueCode(this.txt_input.EditText, this.txt_Count.EditText, "", "");
|
|
this.txt_input.EditText = "";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|