예제 #1
0
 /// <summary>
 /// Update a AcItem.
 /// </summary>
 public void Update(Model.AcItem acItem)
 {
     //
     // todo: add other logic here.
     //
     accessor.Update(acItem);
 }
예제 #2
0
 /// <summary>
 /// Insert a AcItem.
 /// </summary>
 public void Insert(Model.AcItem acItem)
 {
     //
     // todo:add other logic here
     //
     accessor.Insert(acItem);
 }
예제 #3
0
        public bool ExistsExcept(Model.AcItem e)
        {
            Hashtable paras = new Hashtable();

            paras.Add("newId", e.Id);
            paras.Add("oldId", Get(e.AcItemId) == null?null:Get(e.AcItemId).Id);
            return(sqlmapper.QueryForObject <bool>("AcItem.existsexcept", paras));
        }
예제 #4
0
 private void simpleButtonA_Click(object sender, EventArgs e)
 {
     APParameterSet.ChooseAcItem f = new Book.UI.AccountPayable.APParameterSet.ChooseAcItem();
     if (f.ShowDialog(this) == DialogResult.OK)
     {
         Model.AcOtherShouldPaymentDetail detail = new Book.Model.AcOtherShouldPaymentDetail();
         Model.AcItem acitem = f.SelectedItem as Model.AcItem;
         detail.AcOtherShouldPaymentDetailId = Guid.NewGuid().ToString();
         detail.AcOtherShouldPaymentId       = this.AcOtherShouldPayment.AcOtherShouldPaymentId;
         detail.LoanName    = acitem.ItemName;
         detail.AcQuantity  = 0;
         detail.AcMoney     = 0;
         detail.AcItemPrice = acitem.ItemPrice;
         detail.AcItemId    = acitem.AcItemId;
         this.AcOtherShouldPayment.Details.Add(detail);
         this.gridControl1.RefreshDataSource();
         this.bindingSource1.Position = this.bindingSource1.IndexOf(detail);
     }
     //Model.AcOtherShouldPaymentDetail detail = new Model.AcOtherShouldPaymentDetail();
     //detail.AcOtherShouldPaymentId = this.AcOtherShouldPayment.AcOtherShouldPaymentId;
     //this.AcOtherShouldPayment.Details.Add(detail);
     //this.gridControl1.RefreshDataSource();
     //this.bindingSource1.Position = this.bindingSource1.IndexOf(detail);
 }
예제 #5
0
        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();
                }
            }
        }
예제 #6
0
 public void Update(Model.AcItem e)
 {
     this.Update <Model.AcItem>(e);
 }
예제 #7
0
 public void Insert(Model.AcItem e)
 {
     this.Insert <Model.AcItem>(e);
 }
        public void Insert(Model.AcOtherShouldPayment acOtherShouldPayment)
        {
            //
            // todo:add other logic here
            //
            Validate(acOtherShouldPayment);

            //获取数据库原有
            IList <Model.AcItem> dbAClist = AcItemaccessor.Select();

            try
            {
                acOtherShouldPayment.InsertTime = DateTime.Now;
                BL.V.BeginTransaction();
                string invoiceKind   = this.GetInvoiceKind().ToLower();
                string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, acOtherShouldPayment.InsertTime.Value.Year);
                string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, acOtherShouldPayment.InsertTime.Value.Year, acOtherShouldPayment.InsertTime.Value.Month);
                string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, acOtherShouldPayment.InsertTime.Value.ToString("yyyy-MM-dd"));
                string sequencekey   = string.Format(invoiceKind);

                SequenceManager.Increment(sequencekey_y);
                SequenceManager.Increment(sequencekey_m);
                SequenceManager.Increment(sequencekey_d);
                SequenceManager.Increment(sequencekey);


                accessor.Insert(acOtherShouldPayment);

                var Qgroup = from Model.AcOtherShouldPaymentDetail acspd in acOtherShouldPayment.Details
                             group acspd by acspd.LoanName;

                foreach (IGrouping <string, Model.AcOtherShouldPaymentDetail> item in Qgroup)
                {
                    if (!string.IsNullOrEmpty(item.Last <Model.AcOtherShouldPaymentDetail>().AcItemId))
                    {
                        Model.AcItem acitem = (from Model.AcItem ac in dbAClist
                                               where ac.AcItemId == item.Last().AcItemId
                                               select ac).First <Model.AcItem>();
                        acitem.ItemPrice = item.Last <Model.AcOtherShouldPaymentDetail>().AcItemPrice;
                        AcItemaccessor.Update(acitem);
                        continue;
                    }

                    if (dbAClist == null || dbAClist.Count == 0)
                    {
                        Model.AcItem acitem = new Book.Model.AcItem();
                        acitem.AcItemId   = Guid.NewGuid().ToString();
                        acitem.AcItemDate = DateTime.Now;
                        acitem.ItemName   = item.Last().LoanName;
                        acitem.ItemPrice  = item.Last().AcItemPrice;
                        AcItemaccessor.Insert(acitem);
                    }
                    else
                    {
                        IList <Model.AcItem> actQ = (from Model.AcItem ac in dbAClist
                                                     where ac.ItemName == item.Last().LoanName
                                                     select ac).ToList();

                        Model.AcItem act = null;
                        if (actQ != null && actQ.Count != 0)
                        {
                            act = actQ.First <Model.AcItem>();
                        }

                        if (act != null)
                        {
                            if (act.ItemPrice != item.Last().AcItemPrice)
                            {
                                act.ItemPrice = item.Last().AcItemPrice;
                                AcItemaccessor.Update(act);
                            }
                        }
                        else
                        {
                            Model.AcItem acitem = new Book.Model.AcItem();
                            acitem.AcItemId   = Guid.NewGuid().ToString();
                            acitem.AcItemDate = DateTime.Now;
                            acitem.ItemName   = item.Last().LoanName;
                            acitem.ItemPrice  = item.Last().AcItemPrice;
                            AcItemaccessor.Insert(acitem);
                        }
                    }
                }

                foreach (Model.AcOtherShouldPaymentDetail acOtherShouldPaymentDetail in acOtherShouldPayment.Details)
                {
                    acOtherShouldPaymentDetail.AcOtherShouldPaymentDetailId = Guid.NewGuid().ToString();
                    acOtherShouldPaymentDetail.AcOtherShouldPaymentId       = acOtherShouldPayment.AcOtherShouldPaymentId;

                    AcOtherShouldPaymentDetailAccessor.Insert(acOtherShouldPaymentDetail);
                }

                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
예제 #9
0
 public bool ExistsExcept(Model.AcItem e)
 {
     return(accessor.ExistsExcept(e));
 }