using DevComponents.DotNetBar.Controls; using DevComponents.DotNetBar.SuperGrid; using POSV.Card; using POSV.Component; 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 DispatchTicketListForm : BusinessForm { public int Status = 0;//状态 public string No = null;//单号 public string TicketId = null;//选中的单据ID public string TicktStatus = null;//选中的单据状态 DispatchTicketResponse response; List detailList; public DispatchTicketListForm() { 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")); radioButton2.Checked = true; this.Focus(); this.noTextBox.Focus(); this.noTextBox.SelectAll(); this.ActiveControl = this.noTextBox; //获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; Status = 4; DispatchTicket(cur, rows); } public void DispatchTicket(int PageNum, int pageSize) { try { var request = new DispatchTicketRequest(); 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.DispatchTicket(request); //成功 if (response.Item1) { List dispatchTicketResponse = response.Item7; foreach (DispatchTicketResponse ticketResponse in dispatchTicketResponse) { switch (ticketResponse.Status) { case 4: ticketResponse.StatusName = "待收货"; break; case 5: ticketResponse.StatusName = "已收货"; break; default: ticketResponse.StatusName = "其他"; break; } } this.pagerControl1.TotalPage = response.Item4; this.pagerControl1.CurrentPage = response.Item5; this.pagerControl1.RecordCount = response.Item3; this.pagerControl1.RowsPerPage = response.Item6; ticketListTable.PrimaryGrid.DataSource = dispatchTicketResponse; } 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 OnCloseTouchClick(object sender, EventArgs e) { //先关闭父窗体 if (this.Owner != null) { this.Owner.Close(); } //再关闭当前窗体 this.Close(); } 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 exitClick(object sender, EventArgs e) { //先关闭父窗体 if (this.Owner != null) { this.Owner.Close(); } //再关闭当前窗体 this.Close(); } private void reciveClick(object sender, EventArgs e) { if ("待收货".Equals(TicktStatus)) { var editForm = new DispatchTicketReceiveForm(response, detailList); editForm.OnTicktQuery += Form_OnTicktQuery; TransparentForm trans = new TransparentForm(this, editForm); trans.Show(this); } else { this.ShowToastNotify(this, "只有[待收货]的配送单才能验收"); return; } } 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 statusName = StringUtils.GetString(row.Cells["statusName"].Value);//单据状态 var ticketNo = StringUtils.GetString(row.Cells["no"].Value);//配送单号 var askGoodsNo = StringUtils.GetString(row.Cells["askGoodsNo"].Value);//要货单号 var logisticsNo = StringUtils.GetString(row.Cells["logisticsNo"].Value);//物流单号 var logisticsName = StringUtils.GetString(row.Cells["logisticsName"].Value);//物流名称 var orderMoney = StringUtils.GetString(row.Cells["orderMoney"].Value);//商品总额 var logisticsFee = StringUtils.GetString(row.Cells["logisticsFee"].Value);//配送费用 var money = StringUtils.GetString(row.Cells["money"].Value);//金额 var ticketDescription = StringUtils.GetString(row.Cells["description"].Value);//要货备注 var address = StringUtils.GetString(row.Cells["address"].Value);//联系地址 var linkMan = StringUtils.GetString(row.Cells["linkMan"].Value);//联系人 var linkTelephone = StringUtils.GetString(row.Cells["linkTelephone"].Value);//联系电话 response = new DispatchTicketResponse(); response.Id = ticketId; response.No = ticketNo; response.AskGoodsNo = askGoodsNo; response.No = ticketNo; response.StatusName = statusName; response.Description = ticketDescription; response.Address = address; response.LinkMan = linkMan; response.LinkTelephone = linkTelephone; response.LogisticsFee =StringUtils.GetDecimal(logisticsFee); response.LogisticsName = logisticsName; response.LogisticsNo = logisticsNo; response.OrderMoney = StringUtils.GetDecimal(orderMoney); response.Money = StringUtils.GetDecimal(money); this.TicketId = ticketId; this.TicktStatus = statusName; DispatchTicketDetail(ticketId, 1, 1000); } else { detailListTable.PrimaryGrid.Rows.Clear(); } } public void DispatchTicketDetail(string ticketId, int PageNum, int pageSize) { try { var request = new DispatchTicketDetailRequest(); request.StoreId = Global.Instance.Authc.StoreId; request.TicketId = ticketId; request.PageNumber = PageNum; request.PageSize = pageSize; var response = StockUtils.DispatchTicketDetail(request); //成功 if (response.Item1) { List dispatchTicketDetailResponse = response.Item7; detailListTable.PrimaryGrid.DataSource = dispatchTicketDetailResponse; detailList = dispatchTicketDetailResponse; } 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 OnTicketDoubleClick(object sender, DevComponents.DotNetBar.SuperGrid.GridRowDoubleClickEventArgs e) { if ("待收货".Equals(TicktStatus) ) { var editForm = new DispatchTicketReceiveForm(response, detailList); editForm.OnTicktQuery += Form_OnTicktQuery; TransparentForm trans = new TransparentForm(this, editForm); trans.Show(this); } } private void Form_OnTicktQuery(object sender) { //获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; DispatchTicket(cur, rows); } private void queryClick(object sender, EventArgs e) { //获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; DispatchTicket(cur, rows); } private void in_KeyWord_Enter(object sender, Component.EnterEventArg e) { // 获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; DispatchTicket(cur, rows); } private void cb_change_click(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 = 4; } if ("已收货".Equals(indexT) && obj.Checked) { Status = 5; } //获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; DispatchTicket(cur, rows); } private void OnDetailDataBindingComplete(object sender, GridDataBindingCompleteEventArgs e) { var rows = e.GridPanel.Rows; foreach (GridRow row in rows) { row.Cells["askgoodsAmount"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["askgoodsAmount"].Value)); row.Cells["dispatchAmount"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["dispatchAmount"].Value)); row.Cells["price"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["price"].Value)); row.Cells["money"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["money"].Value)); row.Cells["receiveAmount"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["receiveAmount"].Value)); row.Cells["differenceAmount"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["differenceAmount"].Value)); row.Cells["differenceMoney"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["differenceMoney"].Value)); } } private void OnQueryPageChangeWithObject(object obj) { //获得当前页 int cur = pagerControl1.CurrentPage; //获得每页显示的记录数 int rows = pagerControl1.RowsPerPage; PagerControl pager = obj as PagerControl; if (pager != null) { DispatchTicket(cur, rows); } } } }