using DevComponents.DotNetBar.Controls; using DevComponents.DotNetBar.SuperGrid; using POSV.Template; using POSV.Utils; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace POSV.GuangChang { public partial class GuangChangRefundForm : BusinessForm { private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); private List _orderProductInfo = null; private List _orderProductMake = null; public GuangChangRefundForm(List orderProductInfo,List orderProductMake) { InitializeComponent(); this.controlBox1.Text = "订单退款"; this.controlBox1.ShowApplicationVersion = false; foreach (VposOrderProduct product in orderProductInfo) { product.NowCount = product.Count - product.Rcount; } this._orderProductMake = orderProductMake; this._orderProductInfo = orderProductInfo; //可编辑cell颜色特殊标注 var panel = this.productListTable.PrimaryGrid; Color bgColor = ColorTranslator.FromHtml("193,255,192"); panel.Columns["rfCount"].CellStyles.Default.Background.Color1 = bgColor; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.DesignMode) return; productListTable.PrimaryGrid.DataSource = this._orderProductInfo; } private void OnControlBoxCloseClick(object sender, EventArgs e) { OnCloseTouchClick(sender, e); } private void BtnExitClick(object sender, EventArgs e) { OnCloseTouchClick(sender, e); } private void OnCloseTouchClick(object sender, EventArgs e) { //先关闭父窗体 if (this.Owner != null) { this.Owner.Close(); } //再关闭当前窗体 this.Close(); } private void BtnBackTicketClick(object sender, EventArgs e) { //遍历列信息 var rows = this.productListTable.PrimaryGrid.Rows; if (rows.Count > 0) { decimal totalAmount = 0.00M; List productList = new List(); foreach (var temRow in rows) { GridRow row = temRow as GridRow; var id = StringUtils.GetString(row.Cells["id"].Value); var clientId = StringUtils.GetString(row.Cells["clientId"].Value); var productId = StringUtils.GetString(row.Cells["productId"].Value); var productNo = StringUtils.GetString(row.Cells["productNo"].Value); var productName = StringUtils.GetString(row.Cells["productName"].Value); var productUnitId = StringUtils.GetString(row.Cells["productUnitId"].Value); var productUnitName = StringUtils.GetString(row.Cells["productUnitName"].Value); var seriesId = StringUtils.GetString(row.Cells["seriesId"].Value); var seriesName = StringUtils.GetString(row.Cells["seriesName"].Value); var typePath = StringUtils.GetString(row.Cells["typePath"].Value); var typeId = StringUtils.GetString(row.Cells["typeId"].Value); var typeName = StringUtils.GetString(row.Cells["typeName"].Value); var specId = StringUtils.GetString(row.Cells["specId"].Value); var specName = StringUtils.GetString(row.Cells["specName"].Value); var discountPrice = StringUtils.GetDecimal(row.Cells["discountPrice"].Value); var count = StringUtils.GetDecimal(row.Cells["count"].Value); var rcount = StringUtils.GetDecimal(row.Cells["rcount"].Value); var rfCount = StringUtils.GetDecimal(row.Cells["rfCount"].Value); var rfAmount = StringUtils.GetDecimal(row.Cells["rfAmount"].Value); if (rfCount>0) { VposOrderProduct vposOrderProduct = new VposOrderProduct(); vposOrderProduct.Id = id; vposOrderProduct.ProductId = productId; vposOrderProduct.ProductNo = productNo; vposOrderProduct.ProductName = productName; vposOrderProduct.ProductUnitId = productUnitId; vposOrderProduct.ProductUnitName = productUnitName; vposOrderProduct.SeriesId = seriesId; vposOrderProduct.SeriesName = seriesName; vposOrderProduct.TypePath = typePath; vposOrderProduct.TypeId = typeId; vposOrderProduct.TypeName = typeName; vposOrderProduct.SpecId = specId; vposOrderProduct.SpecName = specName; vposOrderProduct.DiscountPrice = discountPrice; vposOrderProduct.Price = discountPrice; vposOrderProduct.Count = count; vposOrderProduct.Rcount = rcount+ rfCount; vposOrderProduct.RfCount = rfCount; vposOrderProduct.RfAmount = rfAmount; List tempList = new List(); if (_orderProductMake != null && _orderProductMake.Count > 0) { foreach (VposOrderProductMake item in _orderProductMake) { if (item.OrderItemId.Equals(clientId)) { tempList.Add(item); } } } vposOrderProduct.MakeInfo = tempList; productList.Add(vposOrderProduct); totalAmount = totalAmount + rfAmount; } } if (totalAmount<=0) { this.ShowToastNotify(this, "请输入退款数量!"); return; } this.OnAcceptButtonClick(new TransparentEventArgs(TransparentAction.Accept, "rfBack", productList)); OnCloseTouchClick(this, null); } } private void OnBeginEdit(object sender, GridEditEventArgs e) { var cell = e.GridCell; var cellPoint = this.productListTable.PointToScreen(cell.LocationRelative); if (cell.GridColumn.Name == "rfCount") { cellPoint.Y -= this.productListTable.VScrollOffset; var p = NumericKeyboard.CalculateLocation(cellPoint, cell.GridColumn.Width); NumericKeyboard.ShowKeyboard(this, p); } else { var txtForm = new TxtKeyboardForm(StringUtils.GetString(cell.Value)); txtForm.NotifyChanged += (o, args) => { cell.Value = args.Data; }; var trans = new TransparentForm(this, .5, txtForm); trans.Show(this); } } private void OnCellValueChanged(object sender, GridCellValueChangedEventArgs e) { var cell = e.GridCell; if (cell.GridColumn.Name == "rfCount") { var row = cell.GridRow; // 可退数量 var nowCount = StringUtils.FormatDataTwoDigitObject(row.Cells["nowCount"].Value); // 折后单价 var discountPrice = StringUtils.FormatDataTwoDigitObject(row.Cells["discountPrice"].Value); // 录入的数量 var rfCount = StringUtils.FormatDataTwoDigitObject(row.Cells["rfCount"].Value); if (rfCount < 0 ) { this.ShowToastNotify(this, "数量非法"); row.Cells["rfCount"].Value = 0; rfCount = 0; } if (rfCount > nowCount) { row.Cells["rfCount"].Value = nowCount; rfCount = nowCount; } var rfAmount = discountPrice * rfCount; row.Cells["rfAmount"].Value = StringUtils.FormatDataTwoDigitObject(rfAmount); //获取退款总额 decimal totalBackAmount = 0.00M; decimal totalBackCount = 0.00M; var rows = this.productListTable.PrimaryGrid.Rows; if (rows.Count > 0) { foreach (var temRow in rows) { GridRow amountRow = temRow as GridRow; var Money = StringUtils.FormatDataTwoDigitObject(amountRow.Cells["rfAmount"].Value); var Count = StringUtils.FormatDataTwoDigitObject(amountRow.Cells["rfCount"].Value); totalBackAmount = totalBackAmount + Money; totalBackCount = totalBackCount + Count; } } this.labelXRcount.Text = StringUtils.GetString(StringUtils.FormatDataTwoDigitObject(totalBackCount)); this.labelXRmoney.Text = StringUtils.GetString(StringUtils.FormatDataTwoDigitObject(totalBackAmount)); } } private void OnCloseEdit(object sender, GridCloseEditEventArgs e) { NumericKeyboard.CloseKeyboard(); } private void BtnAllBackTicketClick(object sender, EventArgs e) { //遍历列信息 var rows = this.productListTable.PrimaryGrid.Rows; if (rows.Count > 0) { decimal totalAmount = 0.00M; List productList = new List(); foreach (var temRow in rows) { GridRow row = temRow as GridRow; var id = StringUtils.GetString(row.Cells["id"].Value); var clientId = StringUtils.GetString(row.Cells["clientId"].Value); var productId = StringUtils.GetString(row.Cells["productId"].Value); var productNo = StringUtils.GetString(row.Cells["productNo"].Value); var productName = StringUtils.GetString(row.Cells["productName"].Value); var productUnitId = StringUtils.GetString(row.Cells["productUnitId"].Value); var productUnitName = StringUtils.GetString(row.Cells["productUnitName"].Value); var seriesId = StringUtils.GetString(row.Cells["seriesId"].Value); var seriesName = StringUtils.GetString(row.Cells["seriesName"].Value); var typePath = StringUtils.GetString(row.Cells["typePath"].Value); var typeId = StringUtils.GetString(row.Cells["typeId"].Value); var typeName = StringUtils.GetString(row.Cells["typeName"].Value); var specId = StringUtils.GetString(row.Cells["specId"].Value); var specName = StringUtils.GetString(row.Cells["specName"].Value); var discountPrice = StringUtils.GetDecimal(row.Cells["discountPrice"].Value); var count = StringUtils.GetDecimal(row.Cells["count"].Value); var rcount = StringUtils.GetDecimal(row.Cells["rcount"].Value); var rfCount = StringUtils.FormatDataTwoDigitObject(row.Cells["nowCount"].Value); var rfAmount = rfCount * discountPrice; if (rfCount > 0) { VposOrderProduct vposOrderProduct = new VposOrderProduct(); vposOrderProduct.Id = id; vposOrderProduct.ProductId = productId; vposOrderProduct.ProductNo = productNo; vposOrderProduct.ProductName = productName; vposOrderProduct.ProductUnitId = productUnitId; vposOrderProduct.ProductUnitName = productUnitName; vposOrderProduct.SeriesId = seriesId; vposOrderProduct.SeriesName = seriesName; vposOrderProduct.TypePath = typePath; vposOrderProduct.TypeId = typeId; vposOrderProduct.TypeName = typeName; vposOrderProduct.SpecId = specId; vposOrderProduct.SpecName = specName; vposOrderProduct.DiscountPrice = discountPrice; vposOrderProduct.Price = discountPrice; vposOrderProduct.Count = count; vposOrderProduct.Rcount = rcount + rfCount; vposOrderProduct.RfCount = rfCount; vposOrderProduct.RfAmount = rfAmount; List tempList = new List(); if (_orderProductMake != null && _orderProductMake.Count > 0) { foreach (VposOrderProductMake item in _orderProductMake) { if (item.OrderItemId.Equals(clientId)) { tempList.Add(item); } } } vposOrderProduct.MakeInfo = tempList; productList.Add(vposOrderProduct); totalAmount = totalAmount + rfAmount; } } if (totalAmount <= 0) { this.ShowToastNotify(this, "订单已全额退款!"); return; } this.OnAcceptButtonClick(new TransparentEventArgs(TransparentAction.Accept, "rfBack", productList)); OnCloseTouchClick(this, null); } } } }