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.

218 lines
7.3 KiB
C#

9 months ago
using DevComponents.DotNetBar.Controls;
using POSV.Card;
using POSV.Report;
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 ProductStockOutSummaryForm : BusinessForm
{
public int GoodsType = 0;//状态
public ProductStockOutSummaryForm()
{
InitializeComponent();
this.controlBox1.Text = "门店商品耗料汇总";
this.controlBox1.ShowApplicationVersion = false;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
BuilderOrderGrid();
if (this.DesignMode) return;
this.startPicker.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
this.endPicker.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
this.Focus();
this.noTextBox.Focus();
this.noTextBox.SelectAll();
this.ActiveControl = this.noTextBox;
GoodsType = -1;
}
public void ProductStockQuery(int PageNum, int pageSize)
{
try
{
var request = new ProductStockOutSummaryRequest();
request.StoreId = Global.Instance.Authc.StoreId;
request.GoodsType = GoodsType;
request.Keyword = this.noTextBox.Text;
request.PageNumber = PageNum;
request.PageSize = pageSize;
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.ProductStockOutSummary(request);
//成功
if (response.Item1)
{
this.ShowToastNotify(this, response.Item2);
StockPagerResponse<ProductStockOutSummaryResponse> stockPagerResponse = response.Item3;
this.pagerControl1.TotalPage = stockPagerResponse.PageCount;
this.pagerControl1.CurrentPage = stockPagerResponse.PageNumber;
this.pagerControl1.RecordCount = stockPagerResponse.TotalCount;
this.pagerControl1.RowsPerPage = stockPagerResponse.PageSize;
detailGrid.PrimaryGrid.DataSource = stockPagerResponse.List;
}
else
{
List<ProductStockOutSummaryResponse> list = new List<ProductStockOutSummaryResponse>();
detailGrid.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)
{
//先关闭父窗体
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 queryClick(object sender, EventArgs e)
{
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
ProductStockQuery(cur, rows);
}
private void BuilderOrderGrid()
{
var panel = detailGrid.PrimaryGrid;
panel.DefaultRowHeight = 40;
panel.RowHeaderIndexOffset = 1;
var cols = ReportUtils.GetGridObject("POSV.Stock.", "ProductStockOutSummary.json");
if (cols != null)
{
Assembly asmb = Assembly.LoadFrom("DevComponents.DotNetBar.SuperGrid.dll");
foreach (var col in cols)
{
panel.Columns.Add(new DevComponents.DotNetBar.SuperGrid.GridColumn()
{
Name = col.Name,
HeaderText = col.HeaderText,
DataPropertyName = col.DataPropertyName,
Visible = col.Display,
Width = col.Width,
AllowEdit = col.AllowEdit,
EditorType = asmb.GetType(col.EditorType, true)
});
}
}
else
{
panel.NoRowsText = "加载报表错误,请联系管理员";
}
}
private void OnPageChange(object obj)
{
queryClick(obj, null);
}
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)
{
GoodsType = -1;
}
if ("普通商品".Equals(indexT) && obj.Checked)
{
GoodsType = 0;
}
if ("成品".Equals(indexT) && obj.Checked)
{
GoodsType = 1;
}
if ("原料".Equals(indexT) && obj.Checked)
{
GoodsType = 10;
}
if ("辅料".Equals(indexT) && obj.Checked)
{
GoodsType = 11;
}
if ("半成品".Equals(indexT) && obj.Checked)
{
GoodsType = 12;
}
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
ProductStockQuery(cur, rows);
}
private void In_keyword_Enter(object sender, Component.EnterEventArg e)
{
//获得当前页
int cur = pagerControl1.CurrentPage;
//获得每页显示的记录数
int rows = pagerControl1.RowsPerPage;
ProductStockQuery(cur, rows);
}
}
}