//计算金额 private void CalculateMoney() { if (this.bindingSource1.DataSource != null) { IList <Model.AcOtherShouldPaymentDetail> list = this.bindingSource1.DataSource as IList <Model.AcOtherShouldPaymentDetail>; global::Helper.TaxType t = (Helper.TaxType) this.TaxType.SelectedIndex; if (list != null && list.Count > 0) { decimal mInvoiceTax = 0; //税额 foreach (Model.AcOtherShouldPaymentDetail d in list) { if (d.TaxCalualateDictionary != null) { d.AcItemPrice = d.TaxCalualateDictionary[t].UnitPrice; d.AcMoney = d.TaxCalualateDictionary[t].UnitMoney; mInvoiceTax += d.TaxCalualateDictionary[t].UnitTaxMoney; //单笔税额统计 } } //GivenControlsValue //税额 this.calcTaxRateMoney.EditValue = this.AcOtherShouldPayment.InvoiceTax = mInvoiceTax; //合计 this.calcHeJiMoney.EditValue = this.AcOtherShouldPayment.InvoiceHeji = this.AcOtherShouldPayment.Details.Sum(d => d.AcMoney); //总额 this.calcZongEMoney.EditValue = this.AcOtherShouldPayment.InvoiceTax + this.AcOtherShouldPayment.InvoiceHeji; //发票金额 this.calcFPMoney.EditValue = this.calcZongEMoney.EditValue; } } }
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column == this.colAcMoney) { Model.AcOtherShouldCollectionDetail CurrentDetail = this.AcOtherShouldCollection.Details[e.RowHandle]; double?mInvoiceTaxrate = (calcTaxRate.EditValue == null || string.IsNullOrEmpty(this.calcTaxRate.EditValue.ToString())) ? 0 : double.Parse(this.calcTaxRate.EditValue.ToString()); global::Helper.TaxType t = (Helper.TaxType) this.TaxType.SelectedIndex; CurrentDetail.AcMoney = this.GetDecimal(CurrentDetail.AcMoney.HasValue ? CurrentDetail.AcMoney.Value : 0, BL.V.SetDataFormat.CGJEXiao.Value); CurrentDetail.TaxCalualateDictionary = new global::Helper.TaxCalculateHelper(t, mInvoiceTaxrate.Value, mInvoiceTaxrate.Value, CurrentDetail.AcMoney.Value, 1).TaxCalculateDictionary; this.CalculateMoney(); this.gridControl1.RefreshDataSource(); } }
//更改税率 private void calcTaxRate_EditValueChanged(object sender, EventArgs e) { if (this.action != "view") { double?mInvoiceTaxrate = (calcTaxRate.EditValue == null || string.IsNullOrEmpty(this.calcTaxRate.EditValue.ToString())) ? 0 : double.Parse(this.calcTaxRate.EditValue.ToString()); IList <Model.AcOtherShouldCollectionDetail> list = this.bindingSource1.DataSource as IList <Model.AcOtherShouldCollectionDetail>; global::Helper.TaxType t = (Helper.TaxType) this.TaxType.SelectedIndex; if (list != null && list.Count > 0) { foreach (Model.AcOtherShouldCollectionDetail d in list) { d.TaxCalualateDictionary = new global::Helper.TaxCalculateHelper(t, mInvoiceTaxrate.Value, this.AcOtherShouldCollection.InvoiceTaxrate.Value, d.AcMoney.Value, 1).TaxCalculateDictionary; } } this.CalculateMoney(); this.gridControl1.RefreshDataSource(); this.AcOtherShouldCollection.InvoiceTaxrate = mInvoiceTaxrate; } }
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column == this.colAcItemPrice || e.Column == this.colAcQuantity) { Model.AcOtherShouldPaymentDetail CurrentDetail = this.AcOtherShouldPayment.Details[e.RowHandle]; double?mInvoiceTaxrate = (calcTaxRate.EditValue == null || string.IsNullOrEmpty(this.calcTaxRate.EditValue.ToString())) ? 0 : double.Parse(this.calcTaxRate.EditValue.ToString()); global::Helper.TaxType t = (Helper.TaxType) this.TaxType.SelectedIndex; CurrentDetail.AcItemPrice = this.GetDecimal((CurrentDetail.AcItemPrice.HasValue ? CurrentDetail.AcItemPrice.Value : 0), BL.V.SetDataFormat.CGDJXiao.Value); //CurrentDetail.AcQuantity = this.GetDecimal(CurrentDetail.AcQuantity.HasValue ? CurrentDetail.AcQuantity.Value : 0, BL.V.SetDataFormat.CGSLXiao.Value); CurrentDetail.AcMoney = this.GetDecimal(CurrentDetail.AcItemPrice.Value * CurrentDetail.AcQuantity.Value, BL.V.SetDataFormat.CGJEXiao.Value); if (CurrentDetail.AcQuantity.HasValue && CurrentDetail.AcQuantity.Value > 0) { CurrentDetail.TaxCalualateDictionary = new global::Helper.TaxCalculateHelper(t, mInvoiceTaxrate.Value, mInvoiceTaxrate.Value, CurrentDetail.AcMoney.Value, CurrentDetail.AcQuantity.Value).TaxCalculateDictionary; this.CalculateMoney(); } this.gridControl1.RefreshDataSource(); //this.CalcHeJI(); } if (e.Column == this.colLoanName) { Model.AcOtherShouldPaymentDetail CurrentDetail = this.AcOtherShouldPayment.Details[e.RowHandle]; IList <Model.AcItem> acilist = (from Model.AcItem ac in acitemlist where ac.ItemName == CurrentDetail.LoanName select ac).ToList <Model.AcItem>(); if (acilist != null && acilist.Count != 0) { Model.AcItem aci = acilist.First <Model.AcItem>(); CurrentDetail.AcItemId = aci.AcItemId; CurrentDetail.AcItem = aci; CurrentDetail.LoanName = aci.ItemName; double?mInvoiceTaxrate = (calcTaxRate.EditValue == null || string.IsNullOrEmpty(this.calcTaxRate.EditValue.ToString())) ? 0 : double.Parse(this.calcTaxRate.EditValue.ToString()); global::Helper.TaxType t = (Helper.TaxType) this.TaxType.SelectedIndex; CurrentDetail.AcItemPrice = this.GetDecimal(aci.ItemPrice.HasValue ? aci.ItemPrice.Value : 0, BL.V.SetDataFormat.CGDJXiao.Value); //CurrentDetail.AcQuantity = this.GetDecimal(CurrentDetail.AcQuantity.HasValue ? CurrentDetail.AcQuantity.Value : 0, BL.V.SetDataFormat.CGSLXiao.Value); CurrentDetail.AcMoney = this.GetDecimal(CurrentDetail.AcItemPrice.Value * CurrentDetail.AcQuantity.Value, BL.V.SetDataFormat.CGJEXiao.Value); if (CurrentDetail.AcQuantity.HasValue && CurrentDetail.AcQuantity.Value > 0) { CurrentDetail.TaxCalualateDictionary = new global::Helper.TaxCalculateHelper(t, mInvoiceTaxrate.Value, mInvoiceTaxrate.Value, CurrentDetail.AcMoney.Value, CurrentDetail.AcQuantity.Value).TaxCalculateDictionary; this.CalculateMoney(); } this.gridControl1.RefreshDataSource(); } else { CurrentDetail = new Book.Model.AcOtherShouldPaymentDetail(); CurrentDetail.AcItemPrice = 0; CurrentDetail.AcMoney = 0; CurrentDetail.AcQuantity = 0; this.gridControl1.RefreshDataSource(); } } }