using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
namespace Gs.DevApp.UserControl
{
public partial class SelectCk : DevExpress.XtraEditors.XtraForm
{
///
/// 组织id
///
string _strGuid = "";
///
/// 物料id,为了查询库存
///
string _itemId = "";
private List _filterList = new List();
public SelectCk(string strGuid, string itemId="")
{
_strGuid = strGuid;
_itemId = itemId;
InitializeComponent();
getPageList(1);
Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, null, "", null, null, false);
}
///
/// 查询事件
///
///
///
private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
{
Gs.DevApp.ToolBox.MsgHelper.ShowInformation("该窗体不支持查询,若想更新页面,请点击 刷新");
}
///
/// 刷新事件
///
///
///
private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
{
_filterList.Clear();
getPageList(1);
}
///
///
/// 第几页
/// 每页几条
private void getPageList(int curPage)
{
gcMain.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
_sbSqlWhere += (" and org.fid='" + _strGuid + "'");
var pgq = new PageQueryModel(curPage, 999999, "org.FNumber asc ,a.depot_code", "asc", this._itemId, _sbSqlWhere.ToString());
var json = JsonConvert.SerializeObject(pgq);
try
{
var strReturn =
UtilityHelper.HttpPost("", "MesDepotsManager/GetListPage2", json);
var dd = UtilityHelper.ReturnToTablePage(strReturn);
if (dd.rtnCode > 0)
{
DataTable dt = dd.rtnData.list;
gcMain.BindingContext = new BindingContext();
if (dt.Rows.Count > 0)
{
gcMain.DataSource = dt;
gcMain.ForceInitialize();
gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
}
else
UtilityHelper.SetDefaultTable(gcMain, gridView1);
}
else
{
ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg);
}
}
catch (Exception ex)
{
MsgHelper.Warning("提示:" + ex.Message);
}
}
private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
var rowhandle = gridView1.FocusedRowHandle;
if (rowhandle < 0)
return;
if (e.Button.Index == 0)
{
var dr = gridView1.GetDataRow(rowhandle);
var mxGuid = dr["depotId"].ToString();
if (string.IsNullOrEmpty(mxGuid))
{
return;
}
var mxName = dr["depotName"].ToString();
var list = new List();
list.Add(new
{
guid = mxGuid,
name = mxName,
kcQty = dr["kcQty"].ToString()
});
UpdateParent?.Invoke(this, new UpdateParentEventArgs { DynamicList = list });
Close();
}
}
///
/// 选择后的回调事件
///
public event EventHandler UpdateParent;
}
}