protected void btnRecalculate_Click(object sender, EventArgs e) { try { IList <ActingBill> actingBillList = this.ucNewList.PopulateSelectedData(); if (actingBillList != null && actingBillList.Count > 0) { TheActingBillMgr.RecalculatePrice(actingBillList, this.CurrentUser); this.ShowSuccessMessage("MasterData.ActingBill.Recalculate.Successfully"); DoSearch(); } } catch (BusinessErrorException ex) { this.ShowErrorMessage(ex); } }
protected override void DoSearch() { string partyCode = this.tbPartyCode.Text != string.Empty ? this.tbPartyCode.Text.Trim() : string.Empty; string receiver = this.tbReceiver.Text != string.Empty ? this.tbReceiver.Text.Trim() : string.Empty; string startDate = this.tbStartDate.Text != string.Empty ? this.tbStartDate.Text.Trim() : string.Empty; string endDate = this.tbEndDate.Text != string.Empty ? this.tbEndDate.Text.Trim() : string.Empty; string itemCode = this.tbItemCode.Text != string.Empty ? this.tbItemCode.Text.Trim() : string.Empty; string currency = this.tbCurrency.Text != string.Empty ? this.tbCurrency.Text.Trim() : string.Empty; string externalRece = ExternalReceiptNo.SelectedValue; DateTime?effDateFrom = null; if (startDate != string.Empty) { effDateFrom = DateTime.Parse(startDate); } DateTime?effDateTo = null; if (endDate != string.Empty) { effDateTo = DateTime.Parse(endDate).AddDays(1).AddMilliseconds(-1); } bool needRecalculate = bool.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_RECALCULATE_WHEN_BILL).Value); if (needRecalculate) { IList <ActingBill> allactingBillList = TheActingBillMgr.GetActingBill(partyCode, receiver, effDateFrom, effDateTo, itemCode, currency, this.ModuleType, this.billNo, true); TheActingBillMgr.RecalculatePrice(allactingBillList, this.CurrentUser); } //djin 2013-3-20 内部客户 if (partyCode != string.Empty) { var IsIntern = TheCustomerMgr.LoadCustomer(partyCode).IsIntern; this.tbIsIntern.Value = IsIntern.ToString(); } IList <ActingBill> actingBillList = TheActingBillMgr.GetActingBill(partyCode, receiver, effDateFrom, effDateTo, itemCode, currency, this.ModuleType, this.billNo, null); //djin 2013-3-20 客户回单 var hd = (from b in actingBillList where !string.IsNullOrEmpty(b.ExternalReceiptNo) //!= null select b.ExternalReceiptNo.Substring(0, 2)).Distinct(); ExternalReceiptNo.Items.Clear(); ExternalReceiptNo.Items.Add(new ListItem("ALL", "ALL")); foreach (var i in hd) { ListItem item = new ListItem(i); ExternalReceiptNo.Items.Add(item); } if (externalRece != "ALL") { var afterF = from a in actingBillList where (a.ExternalReceiptNo != null && a.ExternalReceiptNo.Count() >= 2 && a.ExternalReceiptNo.Substring(0, 2) == externalRece) select a; this.ucNewList.BindDataSource(afterF.ToList()); } else { this.ucNewList.BindDataSource(actingBillList != null && actingBillList.Count > 0 ? actingBillList : null); } //this.ucNewList.BindDataSource(actingBillList != null && actingBillList.Count > 0 ? actingBillList : null); this.ucNewList.Visible = true; }
protected void btnConfirm_Click(object sender, EventArgs e) { string partyCode = this.tbPartyCode.Text != string.Empty ? this.tbPartyCode.Text.Trim() : string.Empty; string receiver = this.tbReceiver.Text != string.Empty ? this.tbReceiver.Text.Trim() : string.Empty; string startDate = this.tbStartDate.Text != string.Empty ? this.tbStartDate.Text.Trim() : string.Empty; string endDate = this.tbEndDate.Text != string.Empty ? this.tbEndDate.Text.Trim() : string.Empty; string itemCode = this.tbItemCode.Text != string.Empty ? this.tbItemCode.Text.Trim() : string.Empty; string currency = this.tbCurrency.Text != string.Empty ? this.tbCurrency.Text.Trim() : string.Empty; DateTime?effDateFrom = null; if (startDate != string.Empty) { effDateFrom = DateTime.Parse(startDate); } DateTime?effDateTo = null; if (endDate != string.Empty) { effDateTo = DateTime.Parse(endDate).AddDays(1).AddMilliseconds(-1); } //重新计价 bool needRecalculate = bool.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_RECALCULATE_WHEN_BILL).Value); if (needRecalculate) { IList <ActingBill> allactingBillList = TheActingBillMgr.GetActingBill(partyCode, receiver, effDateFrom, effDateTo, itemCode, currency, this.ModuleType, null, true); TheActingBillMgr.RecalculatePrice(allactingBillList, this.CurrentUser); } IList <ActingBill> actingBillList = TheActingBillMgr.GetActingBill(partyCode, receiver, effDateFrom, effDateTo, itemCode, currency, this.ModuleType, null); if (actingBillList != null && actingBillList.Count > 0) { foreach (ActingBill actingBill in actingBillList) { actingBill.CurrentBillQty = actingBill.BillQty - actingBill.BilledQty; decimal orgAmount = actingBill.UnitPrice * actingBill.CurrentBillQty; actingBill.CurrentDiscount = orgAmount - (actingBill.BillAmount - actingBill.BilledAmount); } IList <Bill> billList = this.TheBillMgr.CreateBill(actingBillList, this.CurrentUser, (this.IsRelease.Checked ? BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT : BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)); ; DetachedCriteria selectCriteria = DetachedCriteria.For(typeof(Bill)); DetachedCriteria selectCountCriteria = DetachedCriteria.For(typeof(Bill)) .SetProjection(Projections.Count("BillNo")); selectCriteria.Add(Expression.Eq("CreateDate", billList[0].CreateDate)); selectCriteria.Add(Expression.Eq("CreateUser.Code", this.CurrentUser.Code)); selectCountCriteria.Add(Expression.Eq("CreateDate", billList[0].CreateDate)); selectCountCriteria.Add(Expression.Eq("CreateUser.Code", this.CurrentUser.Code)); SearchEvent((new object[] { selectCriteria, selectCountCriteria }), null); this.ShowSuccessMessage("MasterData.Bill.BatchCreateSuccessfully"); } else { this.ShowErrorMessage("Bill.Error.EmptyBillDetail"); } }