You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

572 lines
22 KiB
C#

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 AskGoodsListForm : BusinessForm
{
public int Status = 0;//状态
public int PayStatus = 0;//结算状态
public string No = null;//单号
public string TicketId = null;//选中的单据ID
public string TicktStatus = null;//选中的单据状态
//选择的明细列表
AskgoodsTicketResponse response;
List<AskgoodsDetailResponse> detailList;
public AskGoodsListForm()
{
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;
AskgoodsTicket(cur, rows);
}
private void addClick(object sender, EventArgs e)
{
var addForm = new AskGoodsAddForm();
addForm.OnTicktQuery += Form_OnTicktQuery;
TransparentForm trans = new TransparentForm(this, addForm);
trans.Show(this);
}
private void editClick(object sender, EventArgs e)
{
if ("待审核".Equals(TicktStatus) || "驳回".Equals(TicktStatus))
{
var editForm = new AskGoodsEditForm(response, detailList);
editForm.OnTicktQuery += Form_OnTicktQuery;
TransparentForm trans = new TransparentForm(this, editForm);
trans.Show(this);
}
else {
this.ShowToastNotify(this, "只有[待审核、驳回]的要货单才能修改");
return;
}
}
/// <summary>
/// 审核单据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void applyClick(object sender, EventArgs e)
{
try
{
if (!"待审核".Equals(TicktStatus))
{
this.ShowToastNotify(this, "只有[待审核]的要货单才能审核");
return;
}
AskgoodsStatusRequest request = new AskgoodsStatusRequest();
request.StoreId = Global.Instance.BusinessPlanLog.StoreId;
request.TicketId = this.TicketId;
request.Type = 2;
request.Operator = Global.Instance.BusinessPlanLog.WorkerNo;
request.Reason = "审核通过";
var response = StockUtils.AskgoodsStatus(request);
//成功
if (response.Item1)
{
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
AskgoodsTicket(cur, rows);
this.ShowToastNotify(this, response.Item2);
}
else
{
this.ShowToastNotify(this, response.Item2);
}
}
catch (Exception ex)
{
this.ShowToastNotify(this, "要货单审核异常");
LOGGER.Error(ex, "要货单审核异常");
}
}
private void unApplyClick(object sender, EventArgs e)
{
try
{
if (!"已审核".Equals(TicktStatus))
{
this.ShowToastNotify(this, "只有[已审核]的要货单才能反审核");
return;
}
AskgoodsStatusRequest request = new AskgoodsStatusRequest();
request.StoreId = Global.Instance.BusinessPlanLog.StoreId;
request.TicketId = this.TicketId;
request.Type = 4;
request.Operator = Global.Instance.BusinessPlanLog.WorkerNo;
request.Reason = "反审核单据";
var response = StockUtils.AskgoodsStatus(request);
//成功
if (response.Item1)
{
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
AskgoodsTicket(cur, rows);
this.ShowToastNotify(this, response.Item2);
}
else
{
this.ShowToastNotify(this, response.Item2);
}
}
catch (Exception ex)
{
this.ShowToastNotify(this, "要货单审核异常");
LOGGER.Error(ex, "要货单审核异常");
}
}
private void cancelClick(object sender, EventArgs e)
{
try
{
if (!"待审核".Equals(TicktStatus))
{
this.ShowToastNotify(this, "只有[待审核]的要货单才能作废");
return;
}
AskgoodsStatusRequest request = new AskgoodsStatusRequest();
request.StoreId = Global.Instance.BusinessPlanLog.StoreId;
request.TicketId = this.TicketId;
request.Type = 3;
request.Operator = Global.Instance.BusinessPlanLog.WorkerNo;
request.Reason = "作废单据";
var response = StockUtils.AskgoodsStatus(request);
//成功
if (response.Item1)
{
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
AskgoodsTicket(cur, rows);
this.ShowToastNotify(this, response.Item2);
}
else
{
this.ShowToastNotify(this, response.Item2);
}
}
catch (Exception ex)
{
this.ShowToastNotify(this, "要货单审核异常");
LOGGER.Error(ex, "要货单审核异常");
}
}
private void queryClick(object sender, EventArgs e)
{
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
AskgoodsTicket(cur, rows);
}
private void exitClick(object sender, EventArgs e)
{
//先关闭父窗体
if (this.Owner != null)
{
this.Owner.Close();
}
//再关闭当前窗体
this.Close();
}
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 = 0;
}
if ("驳回".Equals(indexT) && obj.Checked)
{
Status = 1;
}
if ("已审核".Equals(indexT) && obj.Checked)
{
Status = 2;
}
if ("已作废".Equals(indexT) && obj.Checked)
{
Status = 3;
}
if ("已配送".Equals(indexT) && obj.Checked)
{
Status = 4;
}
if ("已收货".Equals(indexT) && obj.Checked)
{
Status = 5;
}
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
AskgoodsTicket(cur, rows);
}
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 OnQueryPageChangeWithObject(object obj)
{
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
PagerControl pager = obj as PagerControl;
if (pager != null)
{
AskgoodsTicket(cur, rows);
}
}
public void AskgoodsTicket(int PageNum, int pageSize)
{
try
{
var request = new AskgoodsTicketRequest();
request.StoreId = Global.Instance.Authc.StoreId;
request.No = this.noTextBox.Text;
request.PageNumber = PageNum;
request.PageSize = pageSize;
request.Status = Status;
request.PayStatus = PayStatus;
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.AskgoodsTicket(request);
//成功
if (response.Item1)
{
List<AskgoodsTicketResponse> askgoodsTicketResponse = response.Item7;
foreach (AskgoodsTicketResponse ticketResponse in askgoodsTicketResponse)
{
switch (ticketResponse.Status)
{
case 0:
ticketResponse.StatusName = "待审核";
break;
case 1:
ticketResponse.StatusName = "驳回";
break;
case 2:
ticketResponse.StatusName = "已审核";
break;
case 3:
ticketResponse.StatusName = "作废";
break;
case 4:
ticketResponse.StatusName = "已发货";
break;
case 5:
ticketResponse.StatusName = "已收货";
break;
default:
ticketResponse.StatusName = "其他";
break;
}
switch (ticketResponse.PayStatus)
{
case 0:
ticketResponse.PayStatusName = "未支付";
break;
case 1:
ticketResponse.PayStatusName = "部分支付";
break;
case 2:
ticketResponse.PayStatusName = "已支付";
break;
case 3:
ticketResponse.PayStatusName = "部分退款";
break;
case 4:
ticketResponse.PayStatusName = "全额退款";
break;
case 5:
ticketResponse.PayStatusName = "已结算";
break;
default:
ticketResponse.PayStatusName = "其他";
break;
}
}
this.pagerControl1.TotalPage = response.Item4;
this.pagerControl1.CurrentPage = response.Item5;
this.pagerControl1.RecordCount = response.Item3;
this.pagerControl1.RowsPerPage = response.Item6;
ticketListTable.PrimaryGrid.DataSource = askgoodsTicketResponse;
}
else
{
List<AskgoodsTicketResponse> list = new List<AskgoodsTicketResponse>();
ticketListTable.PrimaryGrid.DataSource = list;
this.ShowToastNotify(this, response.Item2);
}
}
catch (Exception ex)
{
this.ShowToastNotify(this, "要货单列表查询异常");
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 statusName = StringUtils.GetString(row.Cells["statusName"].Value);
response = new AskgoodsTicketResponse();
var ticketNo = StringUtils.GetString(row.Cells["no"].Value);
var ticketDescription = StringUtils.GetString(row.Cells["description"].Value);
var productMoney = StringUtils.GetString(row.Cells["productMoney"].Value);
var dispatchMoney = StringUtils.GetString(row.Cells["dispatchMoney"].Value);
var totalMoney = StringUtils.GetString(row.Cells["totalMoney"].Value);
var deliveryMode = StringUtils.GetString(row.Cells["deliveryMode"].Value);
var deliveryModeDesc = StringUtils.GetString(row.Cells["deliveryModeDesc"].Value);
var setMan = StringUtils.GetString(row.Cells["setMan"].Value);
var checkMan = StringUtils.GetString(row.Cells["checkMan"].Value);
response.Id = ticketId;
response.No = ticketNo;
response.SetMan = setMan;
response.CheckMan = checkMan;
response.StatusName = statusName;
response.Description = ticketDescription;
response.ProductMoney = productMoney;
response.DispatchMoney = dispatchMoney;
response.TotalMoney = totalMoney;
response.DeliveryMode = deliveryMode;
response.DeliveryModeDesc = deliveryModeDesc;
this.TicketId = ticketId;
this.No = ticketNo;
this.TicktStatus = statusName;
AskgoodsTicketDetail(ticketId, 1, 1000);
}
else
{
detailListTable.PrimaryGrid.Rows.Clear();
}
}
public void AskgoodsTicketDetail(string ticketId, int PageNum, int pageSize)
{
try
{
var request = new AskgoodsDetailRequest();
request.StoreId = Global.Instance.Authc.StoreId;
request.TicketId = ticketId;
request.PageNumber = PageNum;
request.PageSize = pageSize;
var response = StockUtils.AskgoodsDetail(request);
//成功
if (response.Item1)
{
List<AskgoodsDetailResponse> askgoodsDetailResponse = response.Item7;
detailListTable.PrimaryGrid.DataSource = askgoodsDetailResponse;
detailList = askgoodsDetailResponse;
}
else
{
List<AskgoodsDetailResponse> list = new List<AskgoodsDetailResponse>();
detailListTable.PrimaryGrid.DataSource = list;
detailList = list;
this.ShowToastNotify(this, response.Item2);
}
}
catch (Exception ex)
{
this.ShowToastNotify(this, "要货单明细查询异常");
LOGGER.Error(ex, "要货单明细查询异常");
}
}
private void Form_OnTicktQuery(object sender)
{
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
AskgoodsTicket(cur, rows);
}
private void OnTicketDoubleClick(object sender, GridRowDoubleClickEventArgs e)
{
if ("待审核".Equals(TicktStatus) || "驳回".Equals(TicktStatus))
{
var editForm = new AskGoodsEditForm(response, detailList);
editForm.OnTicktQuery += Form_OnTicktQuery;
TransparentForm trans = new TransparentForm(this, editForm);
trans.Show(this);
}
}
/// <summary>
/// 输入单号按回车
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void in_KeyWord_Enter(object sender, EnterEventArg e)
{
// 获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
AskgoodsTicket(cur, rows);
}
private void OnOrderDataBindingComplete(object sender, GridDataBindingCompleteEventArgs e)
{
var rows = e.GridPanel.Rows;
foreach (GridRow row in rows)
{
row.Cells["productMoney"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["productMoney"].Value));
row.Cells["dispatchMoney"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["dispatchMoney"].Value));
row.Cells["totalMoney"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["totalMoney"].Value));
}
}
private void OnDetailDataBindingComplete(object sender, GridDataBindingCompleteEventArgs e)
{
var rows = e.GridPanel.Rows;
foreach (GridRow row in rows)
{
row.Cells["packUnitAmount"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["packUnitAmount"].Value));
row.Cells["amount"].Value = StringUtils.FormatDataTwoDigit(Convert.ToDecimal(row.Cells["amount"].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));
}
}
/// <summary>
/// 打印要货单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnPrint(object sender, EventArgs e)
{
if (response != null && detailList.Count > 0)
{
this.ShowToastNotify(this, "开始打印");
//构建收银小票模版参数
var vars = StockHelper.BuilderAskGoodsVariable(response, detailList);
Tuple<bool, string> result = StockHelper.PrinterTicket("要货单_通用模版", vars, true, false);
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
}
else
{
this.ShowToastNotify(this, "请选择要打印的要货单!");
}
}
}
}