using Gs.DevApp.Entity;
|
using Gs.DevApp.ToolBox;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace Gs.DevApp.DevFrm
|
{
|
public partial class Frm_ArrivalBarcode : DevExpress.XtraEditors.XtraForm
|
{
|
string _webServiceName = "VArrivalBarcodeManager/";
|
List<FilterEntity> _filterList = new List<FilterEntity>();
|
public Frm_ArrivalBarcode()
|
{
|
InitializeComponent();
|
this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
|
this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
|
toolBarMenu1.btnReportClick += ToolBarMenu1_btnReportClick;
|
toolBarMenu1.btnDesignClick += ToolBarMenu1_btnDesignClick;
|
gcMain.MouseDoubleClick += GcMain_MouseDoubleClick;
|
getPageList(1, UtilityHelper.GetPageSize());
|
pageBar1.PagerEvent += PageBar1_PagerEvent;
|
gridView1.CustomDrawRowIndicator += (s, e) =>
|
{
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
{
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
}
|
};
|
gridView1.CustomDrawEmptyForeground += (s, e) =>
|
{
|
string str = "暂未查找到匹配的数据!";
|
Font f = new Font("微软雅黑", 16);
|
Rectangle r = new Rectangle(gridView1.GridControl.Width / 2 - 100, e.Bounds.Top + 45, e.Bounds.Right - 5, e.Bounds.Height - 5);
|
e.Graphics.DrawString(str, f, Brushes.Gray, r);
|
};
|
//设置仓库选择
|
this.txt_depotsId.KeyFile = "depotId";
|
this.txt_depotsId.EditChanged += (s, e) =>
|
{
|
txtDepotsId.Text = this.txt_depotsId.GetId();
|
};
|
//设置供应商选择
|
this.txt_suppId.KeyFile = "id";
|
this.txt_suppId.EditChanged += (s, e) =>
|
{
|
txtSupplierId.Text = this.txt_suppId.GetId();
|
};
|
gcMx1.MouseClick += GcMx1_MouseClick;
|
}
|
private void GcMx1_MouseClick(object sender, MouseEventArgs e)
|
{
|
string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gvMx1, e, "guid");
|
if (string.IsNullOrEmpty(rowGuid))
|
return;
|
lbMxGuid.Text = rowGuid;
|
toolBarMenu1.guidKey = rowGuid;
|
var info = gvMx1.CalcHitInfo(e.Location);
|
var view = info.View;
|
var row = view.GetDataRow(info.RowHandle);
|
txtWlid.Text = row["itemId"].ToString();
|
txtWlgg.Text = row["itemModel"].ToString();
|
txtWlmc.Text = row["itemName"].ToString();
|
txtQuantity.Text = row["Quantity"].ToString();
|
kyPrtQty.Text = row["kyPrtQty"].ToString();
|
}
|
/// <summary>
|
/// 双击事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void GcMain_MouseDoubleClick(object sender, MouseEventArgs e)
|
{
|
string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gridView1, e, "guid");
|
if (!string.IsNullOrEmpty(rowGuid))
|
getModel(rowGuid, false, 999);
|
}
|
/// <summary>
|
/// 分页事件
|
/// </summary>
|
/// <param name="curPage"></param>
|
/// <param name="pageSize"></param>
|
private void PageBar1_PagerEvent(int curPage, int pageSize)
|
{
|
getPageList(curPage, pageSize);
|
}
|
/// <summary>
|
/// 查询事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
|
{
|
Gs.DevApp.UserControl.ShowFilter frm = new Gs.DevApp.UserControl.ShowFilter(gridView1.Columns, _filterList);
|
frm.UpdateParent += Frm_UpdateParent;
|
frm.ShowDialog();
|
}
|
/// <summary>
|
/// 查询回调
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void Frm_UpdateParent(object sender, UpdateParentEventArgs e)
|
{
|
_filterList = e.FilterList;
|
getPageList(1, pageBar1.RowsCount);
|
}
|
private void ToolBarMenu1_btnDesignClick(object sender, EventArgs e)
|
{
|
toolBarMenu1.guidKey = "";
|
string rowGuid, rowName;
|
(rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
|
lbGuid, txt_billNo, gridView1);
|
toolBarMenu1.guidKey = rowGuid;
|
toolBarMenu1.rptParameter = "rpt_Arrival{}";
|
}
|
private void ToolBarMenu1_btnReportClick(object sender, EventArgs e)
|
{
|
toolBarMenu1.guidKey = "";
|
string rowGuid, rowName;
|
(rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1,
|
lbGuid, txt_billNo, gridView1);
|
toolBarMenu1.guidKey = rowGuid;
|
if (xtraTabControl1.SelectedTabPageIndex == 0)
|
{
|
getModel(rowGuid, false, 999);
|
this.toolBarMenu1.rptParameter = "return false";
|
return;
|
}
|
if (lbMxGuid.Text.Trim().Length < 36)
|
{
|
Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择你要打印的行!");
|
this.toolBarMenu1.rptParameter = "return false";
|
return;
|
}
|
if (string.IsNullOrEmpty(txt_iCount_1.Text.Trim()))
|
{
|
Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码张数!");
|
txt_iCount_1.Focus();
|
this.toolBarMenu1.rptParameter = "return false";
|
return;
|
}
|
if (string.IsNullOrEmpty(txt_psnQty_1.Text.Trim()))
|
{
|
Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码数量!");
|
txt_psnQty_1.Focus();
|
this.toolBarMenu1.rptParameter = "return false";
|
return;
|
}
|
this.toolBarMenu1.rptParameter = "rpt_Arrival{" + ""
|
+ "," + ""
|
+ "," + ""
|
+ "," + txt_iCount_1.Text.Trim()
|
+ "," + txt_psnQty_1.Text.Trim()
|
+ "}";
|
}
|
|
/// <summary>
|
/// 刷新事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
|
{
|
UtilityHelper.JumpToTab(xtraTabControl1, 0);
|
getPageList(1, UtilityHelper.GetPageSize());
|
}
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="curPage">第几页</param>
|
/// <param name="pageSize">每页几条</param>
|
private void getPageList(int curPage, int pageSize)
|
{
|
var _sbSqlWhere = new StringBuilder();
|
foreach (var itm in _filterList)
|
_sbSqlWhere.Append(" and " + itm.fileId + itm.fileOper + "'" +
|
itm.fileValue + "'");
|
var pgq = new PageQueryModel(curPage, pageSize, "create_date",
|
"asc", "", _sbSqlWhere.ToString());
|
var json = JsonConvert.SerializeObject(pgq);
|
try
|
{
|
var strReturn = UtilityHelper.HttpPost("",
|
_webServiceName + "GetListPage", json);
|
var dd = UtilityHelper.ReturnToTablePage(strReturn);
|
var dt = dd.rtnData.list;
|
gcMain.BindingContext = new BindingContext();
|
gcMain.DataSource = dt;
|
gcMain.ForceInitialize();
|
var dddd = dd.rtnData.pages; //总页
|
pageBar1.TotalPages = dddd;
|
pageBar1.RecordCount = dd.rtnData.total; //记录总数
|
pageBar1.CurrentPage = curPage; //当前页
|
pageBar1.RowsCount = pageSize; //每页显示
|
pageBar1.setTxt();
|
}
|
catch (Exception ex)
|
{
|
MsgHelper.Warning("提示:" + ex.Message);
|
}
|
}
|
private void getModel(string strGuid, bool isEdit, int tabIdx)
|
{
|
if (string.IsNullOrEmpty(strGuid))
|
{
|
ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
|
return;
|
}
|
UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
|
var _obj = new
|
{
|
guid = strGuid,//主建
|
};
|
try
|
{
|
string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj));
|
ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
|
if (_rtn.rtnCode > 0)
|
{
|
dynamic dy = _rtn.rtnData;
|
lbGuid.Text = strGuid;
|
List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
|
gvList.Add(gvMx1);
|
UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit, gvList);
|
JArray array1 = new JArray();
|
foreach (var a in dy["list1"])
|
{
|
array1.Add(a);
|
}
|
DataTable dt1 = JsonConvert.DeserializeObject<DataTable>(array1.ToString());
|
if (dt1.Rows.Count > 0)
|
{
|
gcMx1.BindingContext = new BindingContext();
|
gcMx1.DataSource = dt1;
|
gcMx1.ForceInitialize();
|
}
|
else
|
{
|
Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
|
}
|
//foreach (var a in _job["rtnData"]["list3"])
|
//{
|
// list3.Add(a);
|
//}
|
|
//DataTable dt1 = JsonConvert.DeserializeObject<DataTable>(list3.ToString());
|
//if (dt1.Rows.Count > 0)
|
//{
|
// gcMx2.BindingContext = new BindingContext();
|
// gcMx2.DataSource = dt1;
|
// gcMx2.ForceInitialize();
|
//}
|
//else
|
//{
|
// Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx2, gvMx2);
|
//}
|
}
|
else
|
ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
|
}
|
catch (Exception ex)
|
{
|
ToolBox.MsgHelper.Warning("提示:" + ex.Message);
|
}
|
}
|
}
|
}
|