using DevComponents.DotNetBar.Controls; using DevComponents.DotNetBar.SuperGrid; using POSV.Card; using POSV.Component; using POSV.Helper; using POSV.Utils; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Reflection; using System.Text; using System.Windows.Forms; namespace POSV.Stock { public partial class StockCheckTicketForm : BusinessForm { public int Status = 0;//状态 public string No = null;//单号 public string TicketId = null;//选中的单据ID List detailList; public StockCheckTicketForm() { InitializeComponent(); this.controlBox1.Text = "库存盘点单信息"; this.controlBox1.ShowApplicationVersion = false; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.DesignMode) return; //默认设置一周的查询时间 this.startPicker.Value = Convert.ToDateTime(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00")); this.endPicker.Value = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")); radioButton1.Checked = true; this.Focus(); this.noTextBox.Focus(); this.noTextBox.SelectAll(); this.ActiveControl = this.noTextBox; //获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; Status = -1; CheckTicket(cur, rows); } private void queryClick(object sender, EventArgs e) { //获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; CheckTicket(cur, rows); } public void CheckTicket(int PageNum, int pageSize) { try { var request = new StoreStockCheckTicketRequest(); request.StoreId = Global.Instance.Authc.StoreId; request.No = this.noTextBox.Text; request.PageNumber = PageNum; request.PageSize = pageSize; request.Status = Status; request.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"); request.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss"); var response = StockUtils.StoreStockCheckTicket(request); //成功 if (response.Item1) { List storeStockCheckTicketResponse = response.Item3.List; foreach (StoreStockCheckTicketResponse ticketResponse in storeStockCheckTicketResponse) { switch (ticketResponse.Status) { case 0: ticketResponse.StatusName = "新建"; break; case 1: ticketResponse.StatusName = "已审核"; break; case 2: ticketResponse.StatusName = "已作废"; break; default: ticketResponse.StatusName = "其他"; break; } } this.pagerControl1.TotalPage = response.Item3.PageCount; this.pagerControl1.CurrentPage = response.Item3.PageNumber; this.pagerControl1.RecordCount = response.Item3.TotalCount; this.pagerControl1.RowsPerPage = response.Item3.PageSize; ticketListTable.PrimaryGrid.DataSource = storeStockCheckTicketResponse; } else { List list = new List(); ticketListTable.PrimaryGrid.DataSource = list; this.ShowToastNotify(this, response.Item2); } } catch (Exception ex) { this.ShowToastNotify(this, "盘点单查询异常"); LOGGER.Error(ex, "盘点单查询异常"); } } private void exitClick(object sender, EventArgs e) { //先关闭父窗体 if (this.Owner != null) { this.Owner.Close(); } //再关闭当前窗体 this.Close(); } private void OnCloseTouchClick(object sender, EventArgs e) { } private void OnControlBoxKeyboardClick(object sender, EventArgs e) { try { KeyboardType keyboardType = KeyboardType.数字; Type type = this.ActiveControl.GetType(); PropertyInfo pinfo = type.GetProperty("Keyboard"); if (pinfo != null) { keyboardType = (KeyboardType)pinfo.GetValue(this.ActiveControl, null); } var keyboard = Application.OpenForms["VirtualKeyboard"]; if (keyboard == null) { keyboard = new VirtualKeyboard(keyboardType); } ((VirtualKeyboard)keyboard).ShowVirtualKeyboard(this, keyboardType); } catch (Exception ex) { LOGGER.Error(ex, "打开屏幕键盘异常"); } } private void OnTicketRowActivated(object sender, DevComponents.DotNetBar.SuperGrid.GridRowActivatedEventArgs e) { GridPanel grid = e.GridPanel; if (e.NewActiveRow != null) { detailListTable.PrimaryGrid.Rows.Clear(); //先清除其他表数据 GridRow row = e.NewActiveRow as GridRow; grid.SetSelected(e.NewActiveRow, false); grid.SetActiveRow(e.NewActiveRow); var ticketId = StringUtils.GetString(row.Cells["id"].Value); var no = StringUtils.GetString(row.Cells["no"].Value); this.TicketId = ticketId; this.No = no; CheckTicketDetail(ticketId, 1, 1000); } else { detailListTable.PrimaryGrid.Rows.Clear(); } } private void CbChangeClick(object sender, EventArgs e) { var obj = sender as CheckBoxX; var indexT = obj.Tag as string; if ("全部".Equals(indexT) && obj.Checked) { Status = -1; } if ("新建".Equals(indexT) && obj.Checked) { Status = 0; } if ("已审核".Equals(indexT) && obj.Checked) { Status = 1; } if ("已作废".Equals(indexT) && obj.Checked) { Status = 2; } //获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; CheckTicket(cur, rows); } public void CheckTicketDetail(string ticketId, int PageNum, int pageSize) { try { var request = new StoreStockCheckTicketDetailRequest(); request.StoreId = Global.Instance.Authc.StoreId; request.TicketId = ticketId; request.PageNumber = PageNum; request.PageSize = pageSize; var response = StockUtils.StoreStockCheckTicketDetail(request); //成功 if (response.Item1) { List storeStockCheckTicketDetailResponse = response.Item3.List; detailListTable.PrimaryGrid.DataSource = storeStockCheckTicketDetailResponse; detailList = storeStockCheckTicketDetailResponse; } else { List list = new List(); detailListTable.PrimaryGrid.DataSource = list; detailList = list; this.ShowToastNotify(this, response.Item2); } } catch (Exception ex) { this.ShowToastNotify(this, "盘点单明细查询异常"); LOGGER.Error(ex, "盘点单明细查询异常"); } } private void OnDetailDataBindingComplete(object sender, GridDataBindingCompleteEventArgs e) { var rows = e.GridPanel.Rows; foreach (GridRow row in rows) { row.Cells["sysAmount"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["sysAmount"].Value)); row.Cells["checkAmount"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["checkAmount"].Value)); row.Cells["differenceAmount"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["differenceAmount"].Value)); } } private void OnQueryPageChangeWithObject(object obj) { //获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; PagerControl pager = obj as PagerControl; if (pager != null) { CheckTicket(cur, rows); } } private void BtnPrintClick(object sender, EventArgs e) { if (detailList != null && detailList.Count > 0) { this.ShowToastNotify(this, "开始打印"); //构建收银小票模版参数 var vars = StockHelper.BuilderCheckTicketVariable(this.No, detailList); Tuple result = StockHelper.PrinterTicket("盘点单_通用模版", vars, true, false); this.ShowToastNotify(this, string.Format("{0}", result.Item2)); } else { this.ShowToastNotify(this, "请选择要打印的单据"); } } } }