コード例 #1
0
        private Data.Treasury SaveTreasury()
        {
            try
            {
                var treasury = new Data.Treasury();
                if (TreasuryId == Guid.Empty)
                {
                    treasury = new Data.Treasury()
                    {
                        TDate  = DateTime.Now.ToPersian(),
                        TPrice = txtPrice.Text.ToDecimal()
                    };
                }
                else
                {
                    decimal oldPrice = 0;
                    if (TreasuryDetailId != Guid.Empty)
                    {
                        oldPrice = Business.GetTreasuryDetailBusiness().GetById(TreasuryDetailId).TDPrice.ToDecimal();
                    }

                    treasury         = Business.GetTreasuryBusiness().GetById(TreasuryId);
                    treasury.TPrice += -oldPrice + txtPrice.Text.ToDecimal();
                }


                treasury.TNO          = txtNo.Text;
                treasury.Ttype        = Common.Constants.TreasuryType.Recive;
                treasury.TDescription = txtTreasuryDescription.Text;

                Business.GetTreasuryBusiness().Save(treasury);
                TreasuryId = treasury.ID;

                return(treasury);
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
        private Data.Treasury SaveTreasury()
        {
            try
            {
                var treasury = Business.GetTreasuryBusiness().GetById(TreasuryId);
                if (treasury == null)
                {
                    treasury = new Data.Treasury()
                    {
                        TPrice = cmb_noe_daryaft.SelectedValue.ToGUID() == Common.Constants.TreasuryDetailType.Cash ? txtPrice.Text.ToDecimal() : txtChequePrice.Text.ToDecimal()
                    }
                }
                ;
                else
                if (TreasuryDetailId != Guid.Empty)
                {
                    decimal oldPrice = 0;
                    oldPrice         = Business.GetTreasuryDetailBusiness().GetById(TreasuryDetailId).TDPrice.ToDecimal();
                    treasury.TPrice += -oldPrice + (cmb_noe_daryaft.SelectedValue.ToGUID() == Common.Constants.TreasuryDetailType.Cash ? txtPrice.Text.ToDecimal() : txtChequePrice.Text.ToDecimal());
                }

                treasury.TDate        = DateTime.Now.ToPersian();
                treasury.TNO          = txtNo.Text;
                treasury.Ttype        = Common.Constants.TreasuryType.Payment;
                treasury.TDescription = txtTreasuryDescription.Text;

                Business.GetTreasuryBusiness().Save(treasury);
                TreasuryId = treasury.ID;

                return(treasury);
            }
            catch
            {
                throw;
            }
        }