public void DoExport(string path) { try { // DataTable listtb1 = (dataGridView1.DataSource as DataTable); List <ReplenishDetail> list = CommonGlobalCache.ServerProxy.GetReplenishDetail(this.curReplenishOrder.ID); // List<BoundDetail> list = CommonGlobalCache.ServerProxy.GetOutboundDetail(curReturnOrder.OutboundOrderID); // System.Collections.SortedList columns = new System.Collections.SortedList(); List <String> keys = new List <string>(); List <String> values = new List <string>(); int ColNum = 0; foreach (DataGridViewColumn item in dataGridView1.Columns) { ColNum++; keys.Add(item.DataPropertyName); if (item.HeaderText == "XL2") { item.HeaderText = "2XL"; } if (item.HeaderText == "XL3") { item.HeaderText = "3XL"; } if (item.HeaderText == "XL4") { item.HeaderText = "4XL"; } if (item.HeaderText == "XL5") { item.HeaderText = "5XL"; } if (item.HeaderText == "XL6") { item.HeaderText = "6XL"; } values.Add(item.HeaderText); } foreach (ReplenishDetail cItem in list) { cItem.CostumeName = CommonGlobalCache.GetCostumeName(cItem.CostumeID); } List <CellType> cellList = new List <CellType>(); NPOIHelper.hsRowCount = 5; /* CellType curCellI = new CellType(); * curCellI.RowIndex = 0; * curCellI.CellName = ""; * if (ColNum % 2 == 0) * { * * curCellI.CellMergeNum = ColNum / 2 - 1; * } * else * { * curCellI.CellMergeNum = ColNum / 2; * } * cellList.Add(curCellI); */ CellType curCell = new CellType(); curCell.RowIndex = 0; curCell.CellName = "补货申请单"; curCell.Title = true; curCell.CellMergeNum = ColNum; // curCell.CellMergeIndex = 12; cellList.Add(curCell); CellType curCellOrder = new CellType(); curCellOrder.RowIndex = 1; curCellOrder.CellName = "单号:"; curCellOrder.CellMergeNum = 1; cellList.Add(curCellOrder); CellType curCellOrderValue = new CellType(); curCellOrderValue.RowIndex = 1; curCellOrderValue.CellName = curReplenishOrder.ID; curCellOrderValue.CellMergeNum = 2; cellList.Add(curCellOrderValue); CellType curCellCreaterUser = new CellType(); curCellCreaterUser.RowIndex = 1; curCellCreaterUser.CellName = "申请时间"; curCellCreaterUser.CellMergeNum = 1; cellList.Add(curCellCreaterUser); CellType curCellCreaterUserValue = new CellType(); curCellCreaterUserValue.RowIndex = 1; curCellCreaterUserValue.CellName = curReplenishOrder.CreateTime.GetDateTimeFormats('f')[0].ToString(); curCellCreaterUserValue.CellMergeNum = 2; cellList.Add(curCellCreaterUserValue); CellType curCellTime = new CellType(); curCellTime.RowIndex = 2; curCellTime.CellName = "申请店铺"; curCellTime.CellMergeNum = 1; cellList.Add(curCellTime); CellType curCellTimeValue = new CellType(); curCellTimeValue.RowIndex = 2; curCellTimeValue.CellName = curReplenishOrder.ShopName; curCellTimeValue.CellMergeNum = 2; cellList.Add(curCellTimeValue); CellType curCellSource = new CellType(); curCellSource.RowIndex = 2; curCellSource.CellName = "申请人:"; curCellSource.CellMergeNum = 1; cellList.Add(curCellSource); CellType curCellSourceValue = new CellType(); curCellSourceValue.RowIndex = 2; curCellSourceValue.CellName = CommonGlobalCache.GetUserName(curReplenishOrder.RequestGuideID); curCellSourceValue.CellMergeNum = 2; cellList.Add(curCellSourceValue); CellType curCellTarget = new CellType(); curCellTarget.RowIndex = 3; curCellTarget.CellName = "总数量:"; curCellTarget.CellMergeNum = 1; cellList.Add(curCellTarget); CellType curCellTargetValue = new CellType(); curCellTargetValue.RowIndex = 3; curCellTargetValue.CellName = curReplenishOrder.TotalCount.ToString(); curCellTargetValue.CellMergeNum = 2; cellList.Add(curCellTargetValue); CellType curCellTotal = new CellType(); curCellTotal.RowIndex = 3; curCellTotal.CellName = "金额:"; curCellTotal.CellMergeNum = 1; cellList.Add(curCellTotal); CellType curCellTotalValue = new CellType(); curCellTotalValue.RowIndex = 3; curCellTotalValue.CellName = curReplenishOrder.TotalPrice.ToString(); curCellTotalValue.CellMergeNum = 2; cellList.Add(curCellTotalValue); CellType curCellRemark = new CellType(); curCellRemark.RowIndex = 4; curCellRemark.CellName = "备注:"; curCellRemark.CellMergeNum = 1; cellList.Add(curCellRemark); CellType curCellRemarkValue = new CellType(); curCellRemarkValue.RowIndex = 4; curCellRemarkValue.CellName = curReplenishOrder.Remarks.ToString(); curCellRemarkValue.CellMergeNum = 8; cellList.Add(curCellRemarkValue); NPOIHelper.CellValues = cellList; NPOIHelper.Keys = keys.ToArray(); NPOIHelper.Values = values.ToArray(); NPOIHelper.ExportExcel(DataGridViewUtil.ToDataTable(list), path); GlobalMessageBox.Show("导出完毕!"); } catch (Exception ex) { ShowError(ex); } finally { UnLockPage(); } }
//点击出库按钮 private void Save(bool isHang) { try { if (skinComboBoxShopID.DataSource == null || (skinComboBoxShopID.DataSource as List <Shop>).Count == 0) { GlobalMessageBox.Show("没有店铺可以调拨"); return; } /* if (this.guideComboBox1.SelectedIndex == 0 && IsPos) * { * GlobalMessageBox.Show("操作人不能为空!"); * return; * }*/ bool isSuperLen = false; foreach (BoundDetail detail in this.curDetailList) { if ((detail.Price > 0 && detail.Price > Convert.ToDecimal(99999999.99)) || (detail.SalePrice > 0 && detail.SalePrice > Convert.ToDecimal(99999999.99)) || (detail.SumMoney > 0 && detail.SumMoney > Convert.ToDecimal(99999999.99))) { isSuperLen = true; break; } } if (isSuperLen) { GlobalMessageBox.Show("列表中吊牌价、售价或每款总金额不能大于99999999.99"); return; } AllocateOutboundPara item = this.Build(); if (item == null || item.OutboundOrder.TotalCount == 0) { GlobalMessageBox.Show("调拨单为空,不能出库!"); return; } if (action == OperationEnum.Send) { item.ReplenishOrderID = order.ID; } else { item.ReplenishOrderID = null; } if (GlobalMessageBox.Show("是否确认操作?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } //检查库存信息 if (CommonGlobalUtil.EngineUnconnectioned(this)) { return; } InteractResult result = null; if (isHang) { result = CommonGlobalCache.ServerProxy.HangUpAllocateOrder(item); } else { result = CommonGlobalCache.ServerProxy.AllocateOutbound(item); } switch (result.ExeResult) { case ExeResult.Success: if (isHang) { GlobalMessageBox.Show("挂单成功!"); } else { GlobalMessageBox.Show("调拨成功!"); //增加打印功能,先给后台使用 if (this.skinCheckBoxPrint.Checked) { // AllocateOrderPrinter.ExcelTemplatePrint(item, curDetailList); //Column2.Visible = false; //SumMoney.Visible = false; //Column2.Tag = AllocateOrderPrintUtil.PrinterNoCount; //SumMoney.Tag = AllocateOrderPrintUtil.PrinterNoCount; DataGridView dgv = deepCopyDataGridView(); AllocateOrderPrintUtil.Print(item.AllocateOrder, dgv); //SumMoney.Visible = true; //Column2.Visible = true; } //if (CommonGlobalCache.GetParameter(ParameterConfigKey.AllocateInDirectly)?.ParaValue == "1") //{ // if (InboundConfirmCtrl.AutoInbound(item.AllocateOrder)) // { // } //} } ResetAll(true); if (!IsShowOnePage) { TabPageClose(this.CurrentTabPage, this.SourceCtrlType); } break; case ExeResult.Error: GlobalMessageBox.Show(result.Msg); break; default: break; } } catch (Exception ex) { CommonGlobalUtil.ShowError(ex); } finally { CommonGlobalUtil.UnLockPage(this); } }
private void BaseButton_OK_Click(object sender, EventArgs e) { RechargeResult result = RechargeResult.Error; try { /* if (this.guideComboBox1.SelectedIndex == 0) * { * GlobalMessageBox.Show("操作人不能为空"); * return; * }*/ if (this.member == null) { GlobalMessageBox.Show("充值会员不能为空!"); return; } //if (this.member.CardType != 1) //{ // GlobalMessageBox.Show("该会员不是充值卡会员!"); // return; //} // int rechargeMoney = int.Parse(this.skinTextBox_RechargeMoney.SkinTxt.Text); int moneyCash = Decimal.ToInt32(this.skinTextBox_MoneyCash.Value); int moneyBankCard = Decimal.ToInt32(this.skinTextBox_MoneyBankCard.Value); int moneyAlipay = Decimal.ToInt32(this.skinTextBox_MoneyAlipay.Value); int moneyWeiXin = Decimal.ToInt32(this.skinTextBox_MoneyWeiXin.Value); int rechargeMoney = moneyCash + moneyBankCard + moneyAlipay + moneyWeiXin; if (rechargeMoney <= 0) { GlobalMessageBox.Show("充值金额应为正整数,充值失败"); return; } if (CommonGlobalUtil.EngineUnconnectioned(this)) { return; } int donateMoney = int.Parse(this.skinLabel_GiveMoney.Text); decimal balanceNew = this.member.Balance + donateMoney + rechargeMoney; result = CommonGlobalCache.ServerProxy.Recharge(new RechargeRecord() { ID = IDHelper.GetID(OrderPrefix.RechargeRecordOrder, shop.AutoCode), BalanceOld = this.member.Balance, BalanceNew = balanceNew, DonateMoney = donateMoney, MemberID = this.member.PhoneNumber, GuideID = this.guideID, MoneyAlipay = moneyAlipay, MoneyBankCard = moneyBankCard, MoneyCash = moneyCash, MoneyWeiXin = moneyWeiXin, RechargeMoney = rechargeMoney, CreateTime = DateTime.Now, Remarks = this.skinTextBox_Remark.Text, MemberName = this.member.Name, ShopID = shop.ID } ); UnLockPage(); switch (result) { case RechargeResult.Success: RechargeDialogForm form = new RechargeDialogForm(member, rechargeMoney, donateMoney, balanceNew); if (form.ShowDialog() == DialogResult.OK) { } this.member = CommonGlobalCache.ServerProxy.GetOneMember(this.member.PhoneNumber); this.SetMemberLabel(); this.CleanRechargeTextBox(); //20180616充值完成自动关闭! // if (isClose) { //只给POS端收银充值用 TabPageClose(this.CurrentTabPage, this); break; case RechargeResult.MemberIsNotExist: GlobalMessageBox.Show("会员不存在!"); break; case RechargeResult.Error: GlobalMessageBox.Show("内部错误!"); break; default: break; } } catch (Exception ee) { WriteLog(ee); } finally { UnLockPage(); } }
private void baseButton3_Click(object sender, EventArgs e) { try { if (this.guideComboBox1.SelectedIndex == 0) { GlobalMessageBox.Show("该笔单的导购员不能为空!"); return; } string id = IDHelper.GetID(OrderPrefix.RefundOrder, CommonGlobalCache.GetShop(shopID).AutoCode); bool isNoHasGuidFlag = false; bool isSuperlen = false; if (this.retailDetailList != null && this.retailDetailList.Count > 0) { foreach (RetailDetail detail in this.retailDetailList) { if (detail.GuideID == null || detail.GuideID == "") { isNoHasGuidFlag = true; break; } if (Math.Abs(detail.SumMoney) > 0 && Math.Abs(detail.SumMoney) > Convert.ToDecimal(99999999.99)) { isSuperlen = true; break; } } } if (isNoHasGuidFlag) { GlobalMessageBox.Show("导购员不能为空,请检查列表里所有款号的导购员!"); return; } if (isSuperlen) { GlobalMessageBox.Show("请检查列表里所有款号的金额是否大于99999999.99!"); return; } #region 创建RefundCostume对象 RefundCostume costume = new RefundCostume() { RefundOrder = null, RefundDetailList = new List <RetailDetail>() }; int totalCount = 0; decimal totalPrice = 0; decimal totalCost = 0; decimal moneyCash = 0; foreach (RetailDetail detail in this. retailDetailList) { if (detail.IsRefund && detail.RefundCount > 0) { detail.Refunded = true; totalCount += detail.RefundCount; totalPrice += detail.RefundCount * detail.Price; totalCost += detail.RefundCount * detail.CostPrice; moneyCash += detail.SumMoney; detail.SalePrice = detail.Price; costume.RefundDetailList.Add(this.RetailDetailToRefundDetail(detail, id)); } } List <String> costumeIds = new List <string>(); foreach (var item in costume.RefundDetailList) { if (!costumeIds.Contains(item.CostumeID)) { costumeIds.Add(item.CostumeID); } } if (costumeIds != null && costumeIds.Count > 0) { //判断是否又禁用的商品,并提示返回 InteractResult interactResult = GlobalCache.ServerProxy.IsCostumeValid(costumeIds); if (interactResult.ExeResult == ExeResult.Error) { GlobalMessageBox.Show(interactResult.Msg); return; } } RetailOrder refundOrder = new RetailOrder() { ID = id, IsRefundOrder = true, OriginOrderID = string.Empty, //GuideID = (string)("-1".Equals(this.guideComboBox2.SelectedValue) ? string.Empty : this.guideComboBox2.SelectedValue), // OperateGuideID = (string)this.guideComboBox1.SelectedValue, GuideID = (string)this.guideComboBox1.SelectedValue, ShopID = shopID, MemeberID = this.memberIDTextBox2.Text, SalesPromotionID = string.Empty, PromotionText = string.Empty, // TotalMoneyReceived = this.currentRetailCostume.RetailOrder.TotalMoneyReceived, // TotalMoneyReceivedActual = this.currentRetailCostume.RetailOrder.TotalMoneyReceivedActual, MoneyBankCard = 0, MoneyWeiXin = 0, MoneyOther = 0, MoneyAlipay = 0, SmallMoneyRemoved = 0, MoneyChange = 0, TotalCount = totalCount * -1, TotalCost = totalCost * -1, TotalPrice = totalPrice * -1, EntryUserID = CommonGlobalCache.CurrentUserID, MoneyDiscounted = 0,//若是全部退款,折扣金额为原始折扣金额,否则为0 Remarks = this.skinTextBox_RefundReason.SkinTxt.Text.Trim(), CreateTime = DateTime.Now, }; costume.RefundOrder = refundOrder; #endregion costume.RefundOrder.MoneyCash = moneyCash * -1; costume.RefundOrder.MoneyCash2 = costume.RefundOrder.MoneyCash; costume.RefundOrder.MoneyIntegration = 0; costume.RefundOrder.MoneyVipCard = 0; costume.RefundOrder.MoneyVipCardMain = 0; costume.RefundOrder.MoneyVipCardDonate = 0; costume.RefundOrder.CreateTime = dateTimePicker_Start.Value; costume.RefundOrder.EntryTime = DateTime.Now; //总计=现金+积分+VIP卡+优惠券 //这笔单的应收金额 - (不退的那几件以原价* 数量 -满减金额) - (退的那几件)优惠券 costume.RefundOrder.TotalMoneyReceived = costume.RefundOrder.MoneyCash + costume.RefundOrder.MoneyIntegration + costume.RefundOrder.MoneyVipCard; costume.RefundOrder.TotalMoneyReceivedActual = costume.RefundOrder.MoneyCash + costume.RefundOrder.MoneyVipCardMain; costume.RefundOrder.Benefit = costume.RefundOrder.TotalMoneyReceivedActual - costume.RefundOrder.TotalCost; // this.moneyDiscounted = costume.RefundOrder.to- costume.RefundOrder ; costume.IsNotHaveRetailOrder = true; if (Math.Abs(costume.RefundOrder.TotalCount) < 1) { GlobalMessageBox.Show("退货数量不能小于1"); return; } ConfirmRefundForm confirmRefundForm = new ConfirmRefundForm(costume, shopID, dataGridView1); DialogResult result = confirmRefundForm.ShowDialog(); if (result == DialogResult.Cancel) { return; } this.ResetForm(); } catch (Exception ee) { GlobalUtil.ShowError(ee); } }
//当单元格中的金额或折扣值发生变化时,对应修改另一项的值 private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1 && e.ColumnIndex > -1) { try { RetailDetail detail = this.retailDetailList[e.RowIndex]; if (e.ColumnIndex == GuideName.Index) { detail.GuideID = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); } switch (this.dataGridView1.Columns[e.ColumnIndex].HeaderText) { case "折扣": if (balanceRound) { detail.SumMoney = detail.RefundCount * Math.Round(detail.Price * detail.Discount * (decimal)0.01, MidpointRounding.AwayFromZero); detail.SumMoneyActual = detail.SumMoney; } else { detail.SumMoney = detail.Price * detail.Discount * detail.RefundCount * (decimal)0.01; detail.SumMoneyActual = detail.SumMoney; } break; case "金额": detail.Discount = (Math.Round((detail.SumMoney * 100) / (detail.Price * detail.RefundCount), 1, MidpointRounding.AwayFromZero)); break; case "数量": if (balanceRound) { detail.SumMoney = detail.RefundCount * Math.Round(detail.Price * detail.Discount * (decimal)0.01, MidpointRounding.AwayFromZero); detail.SumMoneyActual = detail.SumMoney; } else { detail.SumMoney = detail.Price * detail.Discount * detail.RefundCount * (decimal)0.01; detail.SumMoneyActual = detail.SumMoney; } //268 畅滞排行榜:商品退货后,零售金额变成0 detail.SumCost = detail.CostPrice * detail.RefundCount; break; case "使用优惠券": detail.IsUseTickets = (bool)this.dataGridView1[e.ColumnIndex, e.RowIndex].Value; break; } this.dataGridView1.Refresh(); } catch (Exception ex) { GlobalUtil.WriteLog(ex); GlobalMessageBox.Show("内部错误,金额与折扣转化出错!"); } } }
private void BaseButton_AddCostume_Click(object sender, EventArgs e) { try { int buyCount = int.Parse(this.skinTextBox_bugCount.SkinTxt.Text); if (buyCount <= 0) { GlobalMessageBox.Show("退货数量必须大于0!"); return; } string selectShopid = ValidateUtil.CheckEmptyValue(this.skinComboBoxShopID.SelectedValue); List <Guide> guideList = CommonGlobalCache.GuideList.FindAll(t => t.State == 0 && t.ShopID == selectShopid); this.GuideName.DataSource = guideList; this.GuideName.DisplayMember = "Name"; this.GuideName.ValueMember = "ID"; string defaultGuid = string.Empty; if (this.guideComboBox1.SelectedIndex > 0) { defaultGuid = ValidateUtil.CheckEmptyValue(this.guideComboBox1.SelectedValue); } RetailDetail detail = new RetailDetail() { Costume = this.currentSelectedItem.Costume, CostumeID = this.currentSelectedItem.Costume.ID, CostumeName = this.currentSelectedItem.Costume.Name, ColorName = this.skinComboBox_Color.Text, SizeName = ValidateUtil.CheckEmptyValue(this.skinComboBox_Size.SelectedValue), GuideID = defaultGuid, // 显示自己设置的尺码组和对应的尺码列表 SizeDisplayName = CostumeStoreHelper.GetCostumeSizeName(ValidateUtil.CheckEmptyValue(this.skinComboBox_Size.SelectedValue), CommonGlobalCache.GetSizeGroup(this.currentSelectedItem.Costume.SizeGroupName)), IsRefund = true, RefundCount = buyCount, BuyCount = buyCount, Price = this.currentSelectedItem.Costume.Price, SumMoney = this.currentSelectedItem.Costume.Price * buyCount, SumMoneyActual = this.currentSelectedItem.Costume.Price * buyCount, BrandName = ValidateUtil.CheckNotNullValue(currentSelectedItem.Costume.BrandName), // SinglePrice = this.currentSelectedItem.Costume.Price, IsUseTickets = false, ///288 收银时,商品的备注显示的是商品的备注 //Remarks = this.currentSelectedItem.Costume.Remarks, Discount = 100, DiscountOrigin = 100, AllowReviseDiscount = true,//this.currentSelectedStore.AllowReviseDiscount, CostPrice = this.currentSelectedItem.Costume.CostPrice, SumCost = this.currentSelectedItem.Costume.CostPrice * buyCount, }; if (!this.AddSelectedCostumeToList(detail)) { return; } dataGridViewPagingSumCtrl.BindingDataSource(DataGridViewUtil.ListToBindingList(this.retailDetailList)); this.skinTextBox_bugCount.SkinTxt.Text = "1"; } catch (Exception ee) { CommonGlobalUtil.WriteLog(ee); GlobalMessageBox.Show("添加失败!"); } }
private void DoExport() { try { DataTable list = null; List <String> keys = new List <string>(); List <String> values = new List <string>(); if (this.skinTextBox_costumeID.SkinTxt.Text.Trim() != "" && ValidateUtil.CheckEmptyValue(this.skinComboBox_PfCustomer.SelectedValue) == "") { var dt = new DataTable(typeof(PfCustomerInvoicing).Name); foreach (DataGridViewColumn p in view.Columns) { if (!p.DataPropertyName.Contains("PfCustomerID")) { keys.Add(p.DataPropertyName); if (p.DataPropertyName == "Delivery" || p.DataPropertyName == "Retail" || p.DataPropertyName == "PfCustomerStore") { values.Add("小计" + p.HeaderText); } else if ((p.DataPropertyName.Contains("Delivery") && p.DataPropertyName != "Delivery") || (p.DataPropertyName.Contains("Retail") && p.DataPropertyName != "Retail") || p.DataPropertyName.Contains("PfCustomerStore") && p.DataPropertyName != "PfCustomerStore") { /* int CurColumnindex = -1; * if (p.DataPropertyName.Contains("Delivery")) * { * CurColumnindex= p.Index + 1; * }*/ DataTable curdt = p.DataGridView.DataSource as DataTable; string pfcustomerId = curdt.Rows[0]["PfCustomerID" + p.DataPropertyName.Replace("PfCustomerStore", "").Replace("Retail", "").Replace("Delivery", "")].ToString(); if (pfcustomerId == "0") { for (int i = 0; i < curdt.Rows.Count; i++) { if (curdt.Rows[i]["PfCustomerID" + p.DataPropertyName.Replace("PfCustomerStore", "").Replace("Retail", "").Replace("Delivery", "")].ToString() != "0") { pfcustomerId = curdt.Rows[i]["PfCustomerID" + p.DataPropertyName.Replace("PfCustomerStore", "").Replace("Retail", "").Replace("Delivery", "")].ToString(); break; } } } string CName = PfCustomerCache.PfCustomerList.Find(t => t.ID.Equals(pfcustomerId)).Name; values.Add(CName + p.HeaderText); } else { values.Add(p.HeaderText); } } } list = (DataTable)view.DataSource; } else { if (dataGridView1.DataSource != null && dataGridView1.Rows.Count > 0) { list = (DataTable)this.dataGridView1.DataSource; foreach (DataGridViewColumn item in dataGridView1.Columns) { if (item.Visible) { keys.Add(item.DataPropertyName); values.Add(item.HeaderText); } } } } NPOIHelper.Keys = keys.ToArray(); NPOIHelper.Values = values.ToArray(); NPOIHelper.ExportExcel(list, path); GlobalMessageBox.Show("导出完毕!"); } catch (Exception ex) { ShowError(ex); } finally { UnLockPage(); } }
private void dataGridView_MonthTask_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataGridView view = sender as DataGridView; if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } try { if (CommonGlobalUtil.EngineUnconnectioned(this)) { return; } //当前更改的列 DataGridViewCell cell = view.CurrentCell; //当前绑定数据 MonthTaskSearch item = cell.OwningRow.DataBoundItem as MonthTaskSearch; MonthTask task = item.MonthTasks[e.ColumnIndex - 1]; task.ShopID = item.Shop.ID; int monthIndex = e.ColumnIndex; switch (monthIndex) {//增加了序号 case 1: task.MoneyOfSale = Decimal.ToInt32(item.Target1); task.AutoID = item.AutoID1; break; case 2: task.MoneyOfSale = Decimal.ToInt32(item.Target2); task.AutoID = item.AutoID2; break; case 3: task.MoneyOfSale = Decimal.ToInt32(item.Target3); task.AutoID = item.AutoID3; break; case 4: task.MoneyOfSale = Decimal.ToInt32(item.Target4); task.AutoID = item.AutoID4; break; case 5: task.MoneyOfSale = Decimal.ToInt32(item.Target5); task.AutoID = item.AutoID5; break; case 6: task.MoneyOfSale = Decimal.ToInt32(item.Target6); task.AutoID = item.AutoID6; break; case 7: task.MoneyOfSale = Decimal.ToInt32(item.Target7); task.AutoID = item.AutoID7; break; case 8: task.MoneyOfSale = Decimal.ToInt32(item.Target8); task.AutoID = item.AutoID8; break; case 9: task.MoneyOfSale = Decimal.ToInt32(item.Target9); task.AutoID = item.AutoID9; break; case 10: task.MoneyOfSale = Decimal.ToInt32(item.Target10); task.AutoID = item.AutoID10; break; case 11: task.MoneyOfSale = Decimal.ToInt32(item.Target11); task.AutoID = item.AutoID11; break; case 12: task.MoneyOfSale = Decimal.ToInt32(item.Target12); task.AutoID = item.AutoID12; break; default: break; } //if (task.MoneyOfSale == 0) { // GlobalMessageBox.Show(this.FindForm(), "不能设置为0!"); // dataGridView_RefundDetail.CellValueChanged -= dataGridView_RefundDetail_CellValueChanged; // dataGridView_MonthTask.CellValueChanged -= dataGridView_MonthTask_CellValueChanged; // view.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = clickValue; // view.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true; // dataGridView_RefundDetail.CellValueChanged += dataGridView_RefundDetail_CellValueChanged; // dataGridView_MonthTask.CellValueChanged += dataGridView_MonthTask_CellValueChanged; // //view.CancelEdit(); // //view.RefreshEdit(); view.Refresh(); // return; //} task.Month = item.Year * 100 + monthIndex; task.GuideID = ""; UpdateMonthTaskResult result = CommonGlobalCache.ServerProxy.UpdateMonthTask(task); switch (result) { case UpdateMonthTaskResult.Success: //平摊 AvgDetail(task); break; case UpdateMonthTaskResult.IsLessCurrentMonth: view.CancelEdit(); break; case UpdateMonthTaskResult.Error: view.CancelEdit(); GlobalMessageBox.Show("内部错误!"); break; default: break; } } catch (Exception ee) { ShowError(ee); } finally { UnLockPage(); } }
public void DoExport(string path) { try { // DataTable listtb1 = (dataGridView1.DataSource as DataTable); List <PfOrderDetail> list = CommonGlobalCache.ServerProxy.GetPfOrderDetails(this.curReturnOrder.ID); // List<BoundDetail> list = CommonGlobalCache.ServerProxy.GetOutboundDetail(curReturnOrder.OutboundOrderID); // System.Collections.SortedList columns = new System.Collections.SortedList(); List <String> keys = new List <string>(); List <String> values = new List <string>(); int ColNum = 0; foreach (DataGridViewColumn item in dataGridView1.Columns) { if (item.Visible) { ColNum++; keys.Add(item.DataPropertyName); if (item.HeaderText == "XL2") { item.HeaderText = "2XL"; } if (item.HeaderText == "XL3") { item.HeaderText = "3XL"; } if (item.HeaderText == "XL4") { item.HeaderText = "4XL"; } if (item.HeaderText == "XL5") { item.HeaderText = "5XL"; } if (item.HeaderText == "XL6") { item.HeaderText = "6XL"; } values.Add(item.HeaderText); } } foreach (PfOrderDetail cItem in list) { // cItem.CostumeName = CommonGlobalCache.GetCostumeName(cItem.CostumeID); } List <CellType> cellList = new List <CellType>(); NPOIHelper.hsRowCount = 5; /* CellType curCellI = new CellType(); * curCellI.RowIndex = 0; * curCellI.CellName = ""; * if (ColNum % 2 == 0) * { * * curCellI.CellMergeNum = ColNum / 2 - 1; * } * else * { * curCellI.CellMergeNum = ColNum / 2; * } * cellList.Add(curCellI); */ CellType curCell = new CellType(); curCell.RowIndex = 0; if (curReturnOrder.IsRefundOrder) { curCell.CellName = "批发退货单"; } else { curCell.CellName = "批发发货单"; } if (ColNum % 2 == 0) { curCell.CellMergeNum = ColNum; } else { curCell.CellMergeNum = ColNum; } // curCell.CellMergeIndex = 12; curCell.Title = true; cellList.Add(curCell); CellType curCellOrder = new CellType(); curCellOrder.RowIndex = 1; curCellOrder.CellName = "单号:"; curCellOrder.CellMergeNum = 1; cellList.Add(curCellOrder); CellType curCellOrderValue = new CellType(); curCellOrderValue.RowIndex = 1; curCellOrderValue.CellName = curReturnOrder.ID; curCellOrderValue.CellMergeNum = 2; cellList.Add(curCellOrderValue); CellType curCellCreaterUser = new CellType(); curCellCreaterUser.RowIndex = 1; curCellCreaterUser.CellName = "客户"; curCellCreaterUser.CellMergeNum = 1; cellList.Add(curCellCreaterUser); CellType curCellCreaterUserValue = new CellType(); curCellCreaterUserValue.RowIndex = 1; curCellCreaterUserValue.CellName = curReturnOrder.PfCustomerName; curCellCreaterUserValue.CellMergeNum = 2; cellList.Add(curCellCreaterUserValue); CellType curCellTime = new CellType(); curCellTime.RowIndex = 1; curCellTime.CellName = "开单时间"; curCellTime.CellMergeNum = 1; cellList.Add(curCellTime); CellType curCellTimeValue = new CellType(); curCellTimeValue.RowIndex = 1; curCellTimeValue.CellName = curReturnOrder.CreateTime.GetDateTimeFormats('f')[0].ToString();; curCellTimeValue.CellMergeNum = 2; cellList.Add(curCellTimeValue); CellType curCellSource = new CellType(); curCellSource.RowIndex = 2; curCellSource.CellName = "操作人:"; curCellSource.CellMergeNum = 1; cellList.Add(curCellSource); CellType curCellSourceValue = new CellType(); curCellSourceValue.RowIndex = 2; curCellSourceValue.CellName = curReturnOrder.AdminUserName; curCellSourceValue.CellMergeNum = 2; cellList.Add(curCellSourceValue); CellType curCellTarget = new CellType(); curCellTarget.RowIndex = 2; curCellTarget.CellName = "付款方式:"; curCellTarget.CellMergeNum = 1; cellList.Add(curCellTarget); CellType curCellTargetValue = new CellType(); curCellTargetValue.RowIndex = 2; if (curReturnOrder.PayType == 0) { curCellTargetValue.CellName = "记账"; } if (curReturnOrder.PayType == 1) { curCellTargetValue.CellName = "余额"; } if (curReturnOrder.PayType == 2) { curCellTargetValue.CellName = "现金"; } curCellTargetValue.CellMergeNum = 2; cellList.Add(curCellTargetValue); CellType curCellTotal = new CellType(); curCellTotal.RowIndex = 2; curCellTotal.CellName = "总数量:"; curCellTotal.CellMergeNum = 1; cellList.Add(curCellTotal); CellType curCellTotalValue = new CellType(); curCellTotalValue.RowIndex = 2; curCellTotalValue.CellName = curReturnOrder.TotalCount.ToString(); curCellTotalValue.CellMergeNum = 2; cellList.Add(curCellTotalValue); CellType curCellBalanceOld = new CellType(); curCellBalanceOld.RowIndex = 3; curCellBalanceOld.CellName = "上欠金额:"; curCellBalanceOld.CellMergeNum = 1; cellList.Add(curCellBalanceOld); CellType curCellBalanceValueOld = new CellType(); curCellBalanceValueOld.RowIndex = 3; curCellBalanceValueOld.CellName = curReturnOrder.PaymentBalanceOld.ToString(); curCellBalanceValueOld.CellMergeNum = 2; cellList.Add(curCellBalanceValueOld); CellType curCellCurPay = new CellType(); curCellCurPay.RowIndex = 3; curCellCurPay.CellName = "本次应收金额:"; curCellCurPay.CellMergeNum = 1; cellList.Add(curCellCurPay); CellType curCellCurPayValue = new CellType(); curCellCurPayValue.RowIndex = 3; curCellCurPayValue.CellName = curReturnOrder.TotalPfPrice.ToString(); curCellCurPayValue.CellMergeNum = 2; cellList.Add(curCellCurPayValue); CellType curCellBalance = new CellType(); curCellBalance.RowIndex = 3; curCellBalance.CellName = "应收总额:"; curCellBalance.CellMergeNum = 1; cellList.Add(curCellBalance); CellType curCellBalanceValue = new CellType(); curCellBalanceValue.RowIndex = 3; curCellBalanceValue.CellName = curReturnOrder.PaymentBalance.ToString(); curCellBalanceValue.CellMergeNum = 2; cellList.Add(curCellBalanceValue); CellType curCellRemark = new CellType(); curCellRemark.RowIndex = 4; curCellRemark.CellName = "备注:"; curCellRemark.CellMergeNum = 1; cellList.Add(curCellRemark); CellType curCellRemarkValue = new CellType(); curCellRemarkValue.RowIndex = 4; curCellRemarkValue.CellName = curReturnOrder.Remarks.ToString(); curCellRemarkValue.CellMergeNum = 8; cellList.Add(curCellRemarkValue); NPOIHelper.CellValues = cellList; NPOIHelper.Keys = keys.ToArray(); NPOIHelper.Values = values.ToArray(); NPOIHelper.ExportExcel(DataGridViewUtil.ToDataTable(list), path); GlobalMessageBox.Show("导出完毕!"); } catch (Exception ex) { ShowError(ex); } finally { UnLockPage(); } }
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } DataGridView dataGridView = (DataGridView)sender; try { //检查现有的列表是否有重复名称 List <SizeGroup> sizeGroups = DataGridViewUtil.BindingListToList <SizeGroup>(dataGridView1.DataSource); SizeGroup group = dataGridView1.Rows[e.RowIndex].DataBoundItem as SizeGroup; if (e.ColumnIndex == sizeGroupNameDataGridViewTextBoxColumn.Index) { if (e.FormattedValue == null || String.IsNullOrEmpty(e.FormattedValue.ToString())) { GlobalMessageBox.Show("尺码组名称不能为空!"); dataGridView.CancelEdit(); return; } if (sizeGroups != null) { int index = sizeGroups.FindIndex(t => e.FormattedValue?.ToString() == t.ShowName); if (e.RowIndex != index) { if (index > -1) { GlobalMessageBox.Show("尺码组名称已存在!"); dataGridView.CancelEdit(); return; } } } } else if (e.ColumnIndex >= nameOfFDataGridViewTextBoxColumn.Index && e.ColumnIndex <= nameOfXL6DataGridViewTextBoxColumn.Index) { if (e.FormattedValue == null || String.IsNullOrEmpty(e.FormattedValue.ToString())) { GlobalMessageBox.Show("尺码名称不能为空!"); dataGridView.CancelEdit(); return; } else { //不能重复 string currertKeyValue = e.FormattedValue.ToString(); //排除这一个单元格的判断 foreach (SizeGroup sizeGroup in sizeGroups) { bool checkBool = false; //如果是同一个group,那么只检查不是同个属性的值 if (group == sizeGroup) { if (e.ColumnIndex != nameOfFDataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfF == currertKeyValue; } if (e.ColumnIndex != nameOfXSDataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfXS == currertKeyValue; } if (e.ColumnIndex != nameOfSDataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfS == currertKeyValue; } if (e.ColumnIndex != nameOfMDataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfM == currertKeyValue; } if (e.ColumnIndex != nameOfLDataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfL == currertKeyValue; } if (e.ColumnIndex != nameOfXLDataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfXL == currertKeyValue; } if (e.ColumnIndex != nameOfXL2DataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfXL2 == currertKeyValue; } if (e.ColumnIndex != nameOfXL3DataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfXL3 == currertKeyValue; } if (e.ColumnIndex != nameOfXL4DataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfXL4 == currertKeyValue; } if (e.ColumnIndex != nameOfXL5DataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfXL5 == currertKeyValue; } if (e.ColumnIndex != nameOfXL6DataGridViewTextBoxColumn.Index) { checkBool = checkBool || sizeGroup.NameOfXL6 == currertKeyValue; } } else { //不是同一个GROUP,那么检查所有字段 checkBool = sizeGroup.NameOfF == currertKeyValue || sizeGroup.NameOfS == currertKeyValue || sizeGroup.NameOfM == currertKeyValue || sizeGroup.NameOfL == currertKeyValue || sizeGroup.NameOfXL == currertKeyValue || sizeGroup.NameOfXL2 == currertKeyValue || sizeGroup.NameOfXL3 == currertKeyValue || sizeGroup.NameOfXL4 == currertKeyValue || sizeGroup.NameOfXL5 == currertKeyValue || sizeGroup.NameOfXL6 == currertKeyValue; } if (checkBool) { GlobalMessageBox.Show("尺码名称已存在!"); dataGridView.CancelEdit(); return; } } } } } catch (Exception) { GlobalMessageBox.Show("输入格式错误!"); dataGridView.CancelEdit(); } }