当前位置: 首页>>代码示例>>C#>>正文


C# UnitOfWork.ExplicitCommitTransaction方法代码示例

本文整理汇总了C#中UnitOfWork.ExplicitCommitTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.ExplicitCommitTransaction方法的具体用法?C# UnitOfWork.ExplicitCommitTransaction怎么用?C# UnitOfWork.ExplicitCommitTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnitOfWork的用法示例。


在下文中一共展示了UnitOfWork.ExplicitCommitTransaction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertBonusMergerHistory

        // 积分合并的DB操作  m1:积分并入的会员卡;m2:积分清空的会员卡;
        private bool InsertBonusMergerHistory(string m1id, string m2id)
        {
            bool res = false;

            // 积分 b1:是会员M1的积分;b2:是会员M2的积分
            int b1,b2;

            using (UnitOfWork uow = new UnitOfWork(DBSession.DataLayer))
            {
                DateTime updateTime = DateTime.Now;
                // 积分兑换历史记录
                this.bonusExHis1 = new t_Bonus_Exchange_History(uow);
                this.bonusExHis2 = new t_Bonus_Exchange_History(uow);
                // 会员信息
                t_Member_Info m1 = memberLogic.GetMemberInfoByMemberID(m1id, uow);
                t_Member_Info m2 = memberLogic.GetMemberInfoByMemberID(m2id, uow);
                b1 = m1.Bouns;
                b2 = m2.Bouns;

                // 会员1信息
                this.bonusExHis1.Member_ID = m1;
                this.bonusExHis1.Member_No = m1.Member_No;

                this.bonusExHis2.Member_ID = m2;
                this.bonusExHis2.Member_No = m2.Member_No;

                // 兑换日期
                this.bonusExHis1.Exchange_DateTime = updateTime;
                this.bonusExHis2.Exchange_DateTime = updateTime;

                // 合并积分数
                this.bonusExHis1.Bonus_Num = -1 * b2; // 增加积分
                this.bonusExHis2.Bonus_Num = b2; // 扣除积分
                // 合并后剩余积分
                m1.Bouns = b1 + b2;
                m2.Bouns = 0;

                // 兑换金额
                this.bonusExHis1.Money_Num = 0;
                this.bonusExHis2.Money_Num = 0;

                // 合并后剩余金额
                this.bonusExHis1.Surplus_Money = m1.Balance;
                this.bonusExHis2.Surplus_Money = m2.Balance;

                // 兑换类别:积分合并
                this.bonusExHis1.Bonus_Type = BonusExchangeType.BonusMerger;
                this.bonusExHis2.Bonus_Type = BonusExchangeType.BonusMerger;

                // 备注
                this.bonusExHis1.Comment = this.memoRemark1.Text;
                this.bonusExHis2.Comment = this.memoRemark2.Text;

                //数据状态-正常
                this.bonusExHis1.State = (int)RecordState.Normal;
                this.bonusExHis2.State = (int)RecordState.Normal;
                // 更新者
                this.bonusExHis1.Operator_No = SysParam.OperatorNo;
                this.bonusExHis2.Operator_No = SysParam.OperatorNo;
                m1.Operator_No = SysParam.OperatorNo;
                m2.Operator_No = SysParam.OperatorNo;
                // 更新时间
                m1.Update_DateTime = updateTime;
                m2.Update_DateTime = updateTime;

                try
                {
                    uow.ExplicitBeginTransaction();
                    uow.CommitChanges();

                    hisId = this.bonusExHis1.Exchange_History_ID;

                    uow.ExplicitCommitTransaction();

                    // 积分合并成功
                    ShowInfoMsgBox(MessageConst.info_bonusMegerSuccess);
                    res = true;
                }
                catch
                {
                    // 积分合并失败
                    uow.ExplicitRollbackTransaction();
                    ShowWarnMsgBox(MessageConst.errMsg_BonusMegerFaild);
                }
            }

            return res;
        }
开发者ID:riveryong,项目名称:shopsoft,代码行数:89,代码来源:From092_BonusMerger.cs

示例2: InsertBonusExchangeHistory

        private bool InsertBonusExchangeHistory()
        {
            bool res = false;

            using (UnitOfWork uow = new UnitOfWork(DBSession.DataLayer))
            {
                DateTime updateTime = DateTime.Now;
                // 积分兑换历史记录
                this.bonuxExHis = new t_Bonus_Exchange_History(uow);
                // 会员信息
                this.memberInfo = memberLogic.GetMemberInfoByMemberID(this.MemberId, uow);

                this.bonuxExHis.Member_ID = this.memberInfo;
                this.bonuxExHis.Member_No = this.memberInfo.Member_No;
                this.bonuxExHis.Operator_No = SysParam.OperatorNo;

                // 兑换日期
                this.bonuxExHis.Exchange_DateTime = updateTime;

                // 兑换积分数
                int tempBonus = Convert.ToInt32(this.spnBonus.Value);
                this.bonuxExHis.Bonus_Num = tempBonus;
                // 兑换后剩余积分
                this.bonuxExHis.Surplus_Bonus = this.Bonus - tempBonus;
                this.memberInfo.Bouns = this.Bonus - tempBonus;

                // 兑换金额
                double tempBalance = tempBonus * SysParam.storeInfo.Bonus_to_Money_Ratio;
                this.bonuxExHis.Money_Num = tempBalance;
                this.memberInfo.Balance = tempBalance;

                // 兑换后剩余金额
                this.bonuxExHis.Surplus_Money = this.memberInfo.Balance + tempBalance;
                this.memberInfo.Balance += tempBalance;

                // 兑换类别:积分兑换金额
                this.bonuxExHis.Bonus_Type = BonusExchangeType.MoneyExchange;

                // 备注
                this.bonuxExHis.Comment = this.memoRemark.Text;

                //数据状态-正常
                this.bonuxExHis.State = (int)RecordState.Normal;
                // 更新者
                this.bonuxExHis.Operator_No = SysParam.OperatorNo;

                // 更新时间
                this.memberInfo.Update_DateTime = updateTime;
                // 更新者
                this.memberInfo.Operator_No = SysParam.OperatorNo;

                try
                {
                    uow.ExplicitBeginTransaction();
                    uow.CommitChanges();

                    hisId = this.bonuxExHis.Exchange_History_ID;

                    uow.ExplicitCommitTransaction();

                    // 兑换成功
                    ShowInfoMsgBox(MessageConst.info_BonusExchangeSucces);
                    res = true;
                }
                catch
                {
                    // 积分兑换失败
                    uow.ExplicitRollbackTransaction();
                    ShowWarnMsgBox(MessageConst.errMsg_BonusExchangeFaild);
                }
            }

            return res;
        }
开发者ID:riveryong,项目名称:shopsoft,代码行数:74,代码来源:Form091_BonusEx.cs

示例3: InsertConsumeHistory

        private bool InsertConsumeHistory()
        {
            bool res = false;

            using (UnitOfWork uow = new UnitOfWork(DBSession.DataLayer))
            {
                DateTime updateTime = DateTime.Now;
                this.memberDealHis = new t_Member_Deal_History(uow);
                this.memberInfo = memberLogic.GetMemberInfoByMemberID(this.MemberId, uow);

                this.memberDealHis.Member_ID = this.memberInfo;
                this.memberDealHis.Member_No = this.memberInfo.Member_No;
                this.memberDealHis.Operator_No = SysParam.OperatorNo;

                // 导购
                int guidCnt = 0;
                foreach (CheckedListBoxItem guidItem in this.chklistGuide.SelectedItems)
                {
                    guidCnt += 1;
                    if (guidCnt == 1)
                    {
                        // 导购1
                        this.memberDealHis.Guide_No = guidItem.Value.ToString();
                        this.memberDealHis.Guide_Name = guidItem.Description;
                    }
                    else if (guidCnt == 2)
                    {
                        // 导购2
                        this.memberDealHis.Guide2_No = guidItem.Value.ToString();
                        this.memberDealHis.Guide2_Name = guidItem.Description;
                    }
                    else if (guidCnt == 3)
                    {
                        // 导购3
                        this.memberDealHis.Guide3_No = guidItem.Value.ToString();
                        this.memberDealHis.Guide3_Name = guidItem.Description;
                    }
                    else if (guidCnt == 4)
                    {
                        // 导购4
                        this.memberDealHis.Guide4_No = guidItem.Value.ToString();
                        this.memberDealHis.Guide4_Name = guidItem.Description;
                    }
                }

                // 扣除消费次数
                this.memberDealHis.KouChu_Deal_Time = Convert.ToInt32(this.spnConsumeTimes.Value);

                // 卡内剩余次数
                this.memberDealHis.Leave_Deal_Time = this.ConsumeTimes - Convert.ToInt32(this.spnConsumeTimes.Value);
                this.memberInfo.Leaving_Deal_time = this.ConsumeTimes - Convert.ToInt32(this.spnConsumeTimes.Value);

                // 获得积分
                int tempBonus = Convert.ToInt32(this.spnBonus.Value);
                this.memberDealHis.Get_Bonus = tempBonus;
                this.memberInfo.Bouns += tempBonus;

                // 支付方式
                this.memberDealHis.Pay_Type = PayType.TimePay;

                // 备注
                this.memberDealHis.Comment = this.memoRemark.Text;

                //数据状态-正常
                this.memberDealHis.State = (int)RecordState.Normal;
                // 更新者
                this.memberDealHis.Operator_No = SysParam.OperatorNo;

                // 更新时间
                this.memberInfo.Update_DateTime = updateTime;
                // 更新者
                this.memberInfo.Operator_No = SysParam.OperatorNo;

                try
                {
                    uow.ExplicitBeginTransaction();
                    uow.CommitChanges();

                    hisId = this.memberDealHis.Deal_History_ID;

                    uow.ExplicitCommitTransaction();

                    // 充值成功
                    ShowInfoMsgBox(MessageConst.info_MemberConsumeSucces);
                    res = true;
                }
                catch
                {
                    uow.ExplicitRollbackTransaction();
                    ShowWarnMsgBox(MessageConst.errMsg_ConsumeFaild);
                }
            }

            return res;
        }
开发者ID:riveryong,项目名称:shopsoft,代码行数:95,代码来源:Form072_TimesConsume.cs

示例4: btnSave_Click

        /// <summary>
        /// 保存按钮按下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!CheckIsInput())
            {
                ShowWarnMsgBox(MessageConst.errMsg_noInputCharge);
            }

            int hisId = 0;

            using(UnitOfWork uow = new UnitOfWork(Session.DefaultSession.DataLayer))
            {
                DateTime updateTime = DateTime.Now;

                // 充值记录
                this.memChgHis = new t_Member_Charge_History(uow);
                this.memberInfo = memberLogic.GetMemberInfoByMemberID(this.MemberId, uow);

                memChgHis.Member_ID = this.memberInfo;
                memChgHis.Member_No = this.memberInfo.Member_No;
                // 操作者
                memChgHis.Operator_No = null;
                // 充值日期
                memChgHis.Charge_DateTime = updateTime;
                // 充现金
                memChgHis.Charge_Money = Convert.ToDouble(this.spinBalance.Value);

                // 会员余额 =  现有金额 + 充值金额
                double leaveMoney = memberInfo.Balance + memChgHis.Charge_Money;
                memberInfo.Balance = leaveMoney;
                memChgHis.Balance = leaveMoney;

                // 充消费次数
                memChgHis.Charge_Deal_Time = Convert.ToInt32(this.spinDealTime.Value);

                // 剩余消费次数 =  现有消费次数 + 增加积分
                int dealTime = memberInfo.Leaving_Deal_time + memChgHis.Charge_Deal_Time;
                memberInfo.Leaving_Deal_time = dealTime;
                memChgHis.Deal_Time = dealTime;

                // 充小时
                memChgHis.Charge_UseTime = Convert.ToInt32(this.spinChgHours.Value);
                // 剩余可用小时数
                int remainTime = this.memberInfo.Remaining_Time + memChgHis.Charge_UseTime;
                memChgHis.Remaining_Time = remainTime;
                memberInfo.Remaining_Time = remainTime;

                // 增加积分
                memChgHis.Charge_Bonus = Convert.ToInt32(this.spinBonus.Value);
                // 剩余积分 =  现有积分 + 增加积分
                int leaveBonus = memberInfo.Bouns + memChgHis.Charge_Bonus;
                memberInfo.Bouns = leaveBonus;
                memChgHis.Bonus = leaveBonus;

                // 备注
                memChgHis.Comment = string.IsNullOrEmpty(this.memoComment.Text.Trim()) ? null : this.memoComment.Text.Trim();
                // 实收现金
                memChgHis.YingShouCash = Convert.ToDouble(this.spinYingShou.Value);
                //数据状态-正常
                memChgHis.State = (int)RecordState.Normal;
                // 更新者
                memChgHis.Operator_No = SysParam.OperatorNo;

                // 更新时间
                memberInfo.Update_DateTime = updateTime;
                // 更新者
                memberInfo.Operator_No = SysParam.OperatorNo;

                try
                {
                    uow.ExplicitBeginTransaction();
                    uow.CommitChanges();

                    hisId = memChgHis.Charge_History_ID;

                    uow.ExplicitCommitTransaction();

                    // 充值成功
                    ShowInfoMsgBox(MessageConst.info_MemberChargeSuccess);
                }
                catch
                {
                    uow.ExplicitRollbackTransaction();
                    ShowWarnMsgBox(MessageConst.errMsg_chargeFaild);
                }

            }

            if (chkPrint.Checked)
            {
                // 打印小票
                //hisId  充值记录ID
            }
            this.Close();
        }
开发者ID:riveryong,项目名称:shopsoft,代码行数:99,代码来源:Form061_MoneyRecharge.cs


注:本文中的UnitOfWork.ExplicitCommitTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。