using Gs.DevApp.DevFrm.BasicData; using Gs.DevApp.Entity; using Gs.DevApp.ToolBox; using Gs.DevApp.UserControl; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Threading.Tasks; using System.Windows.Forms; namespace Gs.DevApp.DevFrm { public partial class CKTmkc : DevExpress.XtraEditors.XtraForm { string _webServiceName = "Ck/"; List _filterList = new List(); public CKTmkc() { InitializeComponent(); this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick; this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick; toolBarMenu1.btnPrintClick += ToolBarMenu1_btnPrintClick; this.toolBarMenu1.getXmlConfig(); Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, this, "", "", (value) => { Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0); }); Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) => { getModel(value); }, (value) => { getPageList(this.pageBar1.CurrentPage); },lbGuid); getPageList(1); pageBar1.PagerEvent += PageBar1_PagerEvent; //这是仓库标识卡,仅仅打印 this.ucBtnPrint101.SetPlButton(false); this.ucBtnPrint101.btnPrintClick += (s, e) => { _print101(); }; //加入checkbox begin this.gridView1.CustomDrawColumnHeader += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomDrawColumnHeader(s, e); }; this.gridView1.MouseUp += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.CustomMouseUp(s, e, gcMain1, gridView1); }; this.colChkInt.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; this.colChkInt.OptionsFilter.AllowAutoFilter = false; this.colChkInt.OptionsFilter.AllowFilter = false; this.colChkInt.OptionsFilter.AllowInHeaderSearch = DevExpress.Utils.DefaultBoolean.False; //加入checkbox end } private async void GridView1_ColumnFilterChanged(object sender, EventArgs e) { _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1); await Task.Delay(100); getPageList(1); } /// /// 分页事件 /// /// /// private void PageBar1_PagerEvent(int curPage, int pageSize) { getPageList(curPage); } /// /// 查询事件 /// /// /// private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e) { gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged; gridView1.ActiveFilter.Clear(); gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged; var frm = new ShowFilter(gridView1.Columns, _filterList, this.GetType().FullName); frm.UpdateParent += Frm_UpdateParent; frm.ShowDialog(); } /// /// 查询回调 /// /// /// private void Frm_UpdateParent(object sender, UpdateParentEventArgs e) { _filterList = e.FilterList; getPageList(1); } /// /// 刷新事件 /// /// /// private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) { getPageList(this.pageBar1.CurrentPage); } /// /// /// /// 第几页 /// 每页几条 private void getPageList(int curPage) { gcMain1.DataSource = null;var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList); PageQueryModel pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "a.INDEP_DATE", "asc", "", _sbSqlWhere.ToString()); string json = JsonConvert.SerializeObject(pgq); try { var strReturn = UtilityHelper.HttpPost("", _webServiceName + "GetListPage", json); ReturnModel dd = UtilityHelper.ReturnToTablePage(strReturn); if (dd.rtnCode > 0) { DataTable dt = dd.rtnData.list; gcMain1.BindingContext = new BindingContext(); gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged; if (dt.Rows.Count > 0) { gcMain1.DataSource = dt; gcMain1.ForceInitialize(); gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1); } else UtilityHelper.SetDefaultTable(gcMain1, gridView1); gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged; pageBar1.TotalPages = dd.rtnData.pages;//总页 pageBar1.CurrentPage = curPage;//当前页 pageBar1.RecordCount = dd.rtnData.total;//总记录数 } else { ToolBox.MsgHelper.ShowError("提示:" + dd.rtnMsg); } } catch (Exception ex) { ToolBox.MsgHelper.ShowError("提示:" + ex.Message); } } private void getModel(string strGuid) { bool isEdit = false; if (toolBarMenu1.currentAction == "add") return; if (toolBarMenu1.currentAction == "edit") isEdit = true; if (string.IsNullOrEmpty(strGuid)) { MsgHelper.Warning("请先选择你要操作的行!"); return; } var _obj = new { guid = strGuid //主建 }; try { var strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); var _rtn = UtilityHelper.ReturnToDynamic(strJson); if (_rtn.rtnCode > 0) { var dy = _rtn.rtnData; lbGuid.Text = strGuid; UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit); } else { MsgHelper.Warning("提示:" + _rtn.rtnMsg); } } catch (Exception ex) { MsgHelper.Warning("提示:" + ex.Message); } } /// /// 这是单个打印 /// private void _print101() { string rowGuid, rowName; (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_itemBarcode, gridView1); ucBtnPrint101.guidKey = rowGuid; if (rowGuid.Length < 36) { Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择你要打印的行!"); this.ucBtnPrint101.rptParameter = "return false"; return; } this.ucBtnPrint101.rptParameter = "rpt_cktm{" + "" + "," + "" + "," + "" + "," + "" + "," + "" + "}"; } /// /// 这是批量打印 /// /// /// private void ToolBarMenu1_btnPrintClick(object sender, EventArgs e) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); gridView1.PostEditor(); gridView1.UpdateCurrentRow(); DataTable dt = this.gcMain1.DataSource as DataTable; { foreach (DataRow dr in dt.Rows) { string checkBox = dr["chkInt"].ToString(); string _guid = dr["guid"].ToString(); if (Gs.DevApp.ToolBox.UtilityHelper.ToCheck(checkBox)) { if (sb.Length > 0) sb.Append("|"); sb.Append(_guid); } } } if (string.IsNullOrEmpty(sb.ToString())) { Gs.DevApp.ToolBox.MsgHelper.ShowError("提示:请先选择物料!"); this.toolBarMenu1.rptParameter = "return false"; return; } this.toolBarMenu1.rptParameter = "rpt_cktm{" + "100" + "," + "" + "," + "" + "," + "" + "," + "" + "," + sb.ToString() + "}"; this.toolBarMenu1.guidKey = null; } } }