/// <summary>
        /// 更新销售发汇报
        /// </summary>
        /// <returns></returns>
        public static bool UpdateSellReport(SellReportModel sellrptModel, List <SellReportDetailModel> sellRptDetailModellList, out string strMsg)
        {
            bool isSucc = false;//是否添加成功

            strMsg = "";

            string strSql = "delete from officedba.sellerRate where  sellreportID=@sellreportID  and CompanyCD=@CompanyCD";

            SqlParameter[]     paras = { new SqlParameter("@sellreportID", sellrptModel.ID), new SqlParameter("@CompanyCD", sellrptModel.CompanyCD) };
            TransactionManager tran  = new TransactionManager();

            tran.BeginTransaction();
            try
            {
                UpdateSellReportMain(sellrptModel, tran);
                SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), paras);
                InsertSellReportDetail(sellRptDetailModellList, sellrptModel.ID, tran);
                tran.Commit();
                strMsg = "保存成功!";
                isSucc = true;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                strMsg = "保存失败,请联系系统管理员!";
                throw ex;
            }

            return(isSucc);
        }
        public static bool Insert(SellReportModel sellrptModel, List <SellReportDetailModel> sellRptDetailModellList, out string strMsg)
        {
            bool isSucc = false;//是否添加成功
            int  billID = 0;

            strMsg = "";
            TransactionManager tran = new TransactionManager();

            tran.BeginTransaction();
            try
            {
                billID = InsertSellReport(sellrptModel, tran);
                InsertSellReportDetail(sellRptDetailModellList, billID, tran);
                tran.Commit();
                isSucc = true;
                strMsg = "保存成功!|" + billID;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                strMsg = "保存失败,请联系系统管理员!";
                throw ex;
            }

            return(isSucc);
        }
Ejemplo n.º 3
0
        private void SaveEmployee(Employee employee, TList <Address> addresses)
        {
            TransactionManager transactionManager = null;

            try
            {
                transactionManager = ConnectionScope.CreateTransaction();
                NetTiersProvider dataProvider    = ConnectionScope.Current.DataProvider;
                EmployeeService  employeeService = new EmployeeService();
                dataProvider.EmployeeProvider.Insert(transactionManager, employee);

                foreach (var address in addresses)
                {
                    address.EmployeeId = employee.EmployeeId;
                }
                dataProvider.AddressProvider.Insert(transactionManager, addresses);
                transactionManager.Commit();
                Clear();
            }
            catch (Exception exc)
            {
                if (transactionManager != null && transactionManager.IsOpen)
                {
                    transactionManager.Rollback();
                }
                lblMsg.Text = "An error occurred while processing your request!";
            }
        }
        /// <summary>
        /// 删除销售汇报
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public static bool DelSellRpt(string ids, string strCompanyCD, out string strMsg, out string strFieldText)
        {
            bool isSucc = false;

            strMsg       = "";
            strFieldText = "";
            System.Text.StringBuilder sb   = new System.Text.StringBuilder();
            TransactionManager        tran = new TransactionManager();

            tran.BeginTransaction();
            try
            {
                SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, "DELETE FROM officedba.SellReport WHERE id IN ( " + ids + " ) and CompanyCD='" + strCompanyCD + "'", null);
                SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, "DELETE FROM officedba.sellerRate WHERE sellreportID IN ( " + ids + " ) and CompanyCD='" + strCompanyCD + "'", null);

                tran.Commit();
                isSucc = true;
                strMsg = "删除成功!";
            }
            catch (Exception ex)
            {
                tran.Rollback();
                strMsg = "删除失败,请联系系统管理员!";
                isSucc = false;
                throw ex;
            }
            return(isSucc);
        }
Ejemplo n.º 5
0
        static MessageCode InnerSaveMix(Guid mid, ItemPackageFrame pack, SkillBagWrap bag, ItemInfoEntity mixItems, string setSkills = null)
        {
            string itemMap   = mixItems.ItemId.ToString();
            int    errorCode = (int)MessageCode.FailUpdate;

            using (var tranMgr = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
            {
                tranMgr.BeginTransaction();
                do
                {
                    if (null != pack && !pack.Save(tranMgr.TransactionObject))
                    {
                        break;
                    }
                    NbManagerskillbagMgr.MixUpTran(false, mid, setSkills, bag.SetMap, itemMap, bag.RawBag.RowVersion, ref errorCode);
                }while (false);
                if (errorCode == (int)MessageCode.Success)
                {
                    tranMgr.Commit();
                }
                else
                {
                    tranMgr.Rollback();
                }
            }
            itemMap = null;
            return((MessageCode)errorCode);
        }
Ejemplo n.º 6
0
        static MessageCode InnerSaveMixNew(NbManagerEntity manager, Guid mid, SkillBagWrap bag, int coin, string setSkills = null)
        {
            int errorCode = (int)MessageCode.FailUpdate;

            using (var tranMgr = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
            {
                tranMgr.BeginTransaction();
                do
                {
                    var mess = ManagerCore.Instance.CostCoin(manager, coin, EnumCoinConsumeSourceType.SkillUpgrade,
                                                             ShareUtil.GenerateComb().ToString(), tranMgr.TransactionObject);
                    if (mess != MessageCode.Success)
                    {
                        break;
                    }
                    NbManagerskillbagMgr.MixUpTran(false, mid, setSkills, bag.SetMap, "", bag.RawBag.RowVersion, ref errorCode);
                }while (false);
                if (errorCode == (int)MessageCode.Success)
                {
                    tranMgr.Commit();
                }
                else
                {
                    tranMgr.Rollback();
                }
            }
            return((MessageCode)errorCode);
        }
Ejemplo n.º 7
0
        // MessageCode SaveLottery(Guid matchId, Guid managerId, ItemPackageFrame package, MailBuilder mail, int lotteryRepeatCode)
        MessageCode SaveLottery(Guid matchId, Guid managerId, int lotteryRepeatCode, ItemPackageFrame package, MailBuilder mail, int point)
        {
            try
            {
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    //var messageCode = Tran_SaveLottery(transactionManager.TransactionObject, matchId, managerId, package, mail, lotteryRepeatCode);
                    var messageCode = Tran_SaveLottery(transactionManager.TransactionObject, matchId, managerId, lotteryRepeatCode, package, mail, point);

                    if (messageCode == ShareUtil.SuccessCode)
                    {
                        transactionManager.Commit();
                    }
                    else
                    {
                        transactionManager.Rollback();
                    }
                    return(messageCode);
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("SavePlayerKillLottery", ex);
                return(MessageCode.Exception);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Post the active job edits using LTT_POST.POST
        /// </summary>
        /// <returns></returns>
        private bool PostJobEdits()
        {
            IGTApplication app = GTClassFactory.Create <IGTApplication>();

            try
            {
                // Since validations have already been performed, using the LTT_POST.POST to avoid rechecking validations, etc.
                TransactionManager.Begin("Post Job");

                bool returnValue = Handleblanketunitizationactivity();
                app.DataContext.Execute("begin ltt_post.post;end;", out int recs, (int)CommandTypeEnum.adCmdText);

                if (TransactionManager.TransactionInProgress)
                {
                    TransactionManager.Commit(true);
                }

                return(true);
            }
            catch (Exception ex)
            {
                if (TransactionManager.TransactionInProgress)
                {
                    TransactionManager.Rollback();
                }

                app.DataContext.Execute("rollback", out int rec, (int)CommandTypeEnum.adCmdText);
                string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message);
                throw new Exception(exMsg);
            }
        }
Ejemplo n.º 9
0
        MessageCode SaveMatch(NbManagerEntity manager, NbManagerextraEntity managerex, BaseMatchData pkmatchData,
                              Guid lotteryMatchId, int win, int lose, int draw, int prizeExp, int prizeCoin, int prizeItemCode, string prizeItemString
                              , bool isrevenge, long revengeRecordId, ref long outRevengeRecordId, PlayerkillInfoEntity info, int pointCount)
        {
            if (manager == null)
            {
                return(MessageCode.NbUpdateFail);
            }
            try
            {
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    var messageCode = Tran_SaveMatch(transactionManager.TransactionObject, manager, managerex, pkmatchData,
                                                     lotteryMatchId, win, lose, draw, prizeExp, prizeCoin, prizeItemCode, prizeItemString
                                                     , isrevenge, revengeRecordId, ref outRevengeRecordId, info, pointCount);

                    if (messageCode == ShareUtil.SuccessCode)
                    {
                        transactionManager.Commit();
                    }
                    else
                    {
                        transactionManager.Rollback();
                    }
                    return(messageCode);
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("SavePlayerKillMatch", ex);
                return(MessageCode.Exception);
            }
        }
        public void UpdateData()
        {
            if (SessionWorker == null)
            {
                throw new Exception("SessionWorker can not be null");
            }
            DbConnection connection = GetConnection();

            DataSet dataSet = SessionWorker.Object as DataSet;

            if (dataSet == null)
            {
                throw new Exception("Object of SessionWorker is not DataSet");
            }
            Exception     exception  = null;
            List <string> skipTables = new List <string>();

            connection.Open();
            try
            {
                DbTransaction transaction = connection.BeginTransaction();
                UpdateData(transaction, dataSet, skipTables);
                transaction.Commit();
                executeTransaction.Commit();
            }
            catch (Exception e)
            {
                exception = e;
            }
            finally
            {
                connection.Close();
            }
            ThrowException(skipTables, exception);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 删除单据
        /// </summary>
        /// <param name="orderNos"></param>
        /// <returns></returns>
        public static bool DelOrder(string orderIDs)
        {
            string strCompanyCD = string.Empty;//单位编号
            bool   isSucc       = false;

            System.Text.StringBuilder sb   = new System.Text.StringBuilder();
            TransactionManager        tran = new TransactionManager();

            strCompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;


            tran.BeginTransaction();
            try
            {
                SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, "DELETE FROM officedba.AdversarySell WHERE ID IN ( " + orderIDs + " ) and CompanyCD='" + strCompanyCD + "'", null);

                tran.Commit();
                isSucc = true;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                isSucc = false;
                throw ex;
            }
            return(isSucc);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 跟新单据单据
        /// </summary>
        /// <param name="sellChanceModel">销售机会表实体</param>
        /// <param name="sellChancePushModel">销售阶段表实体</param>
        /// <returns>是否添加成功</returns>
        public static bool UpdateOrder(AdversaryInfoModel adversaryInfoModel, List <AdversaryDynamicModel> adversaryDynamicModelList)
        {
            bool   isSucc = false;//是否添加成功
            string strSql = "delete from officedba.AdversaryDynamic where  CustNo=@CustNo  and CompanyCD=@CompanyCD";

            SqlParameter[]     paras = { new SqlParameter("@CustNo", adversaryInfoModel.CustNo), new SqlParameter("@CompanyCD", adversaryInfoModel.CompanyCD) };
            TransactionManager tran  = new TransactionManager();

            tran.BeginTransaction();
            try
            {
                UpdateAdversaryInfo(adversaryInfoModel, tran);
                SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), paras);
                InsertAdversaryDynamic(adversaryDynamicModelList, tran);
                tran.Commit();
                isSucc = true;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                isSucc = false;
                throw ex;
            }


            return(isSucc);
        }
Ejemplo n.º 13
0
        public void Test4()
        {
            IList <string> list = new List <string>();


            try
            {
                using (TransactionManager manager = new TransactionManager())
                {
                    manager.Create(() => { AddName1(list); }, () => { RollbackName1(list); });
                    manager.Create(() => { AddName2(list, true); }, () => { RollbackName2(list); });

                    manager.Commit();
                }
            }
            catch
            {
            }
            bool isContainName1 = list.Contains(NAME_1);

            bool isContainName2 = list.Contains(NAME_2);

            bool status = (!isContainName1 && !isContainName2);

            Assert.IsTrue(status);
        }
Ejemplo n.º 14
0
 MessageCode Save_TranReceiveBindPoint(PayUserEntity payUser, InvestManagerEntity investInfo)
 {
     try
     {
         using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
         {
             transactionManager.BeginTransaction();
             var code = Tran_ReceiveBindPoint(payUser, investInfo, transactionManager.TransactionObject);
             if (code == ShareUtil.SuccessCode)
             {
                 transactionManager.Commit();
             }
             else
             {
                 transactionManager.Rollback();
             }
             return(code);
         }
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("ReceiveBindPoint", ex);
         return(MessageCode.Exception);
     }
 }
Ejemplo n.º 15
0
        public static int EditSubBudget(SubBudgetModel subBudgetModel, XBase.Common.UserInfoUtil userinfo)
        {
            StringBuilder sqlstr = new StringBuilder();

            sqlstr.Append("update officedba.SubBudget set BudgetName=@BudgetName,projectid=@projectid where ID=@ID");
            SqlParameter[] param =
            {
                new SqlParameter("@BudgetName", SqlDbType.VarChar, 200),
                new SqlParameter("@projectid",  SqlDbType.Int,       4),
                new SqlParameter("@ID",         SqlDbType.Int)
            };
            param[0].Value = subBudgetModel.BudgetName;
            param[1].Value = subBudgetModel.Projectid;
            param[2].Value = subBudgetModel.ID;
            TransactionManager tran = new TransactionManager();
            int num = 0;

            tran.BeginTransaction();
            try
            {
                num = SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, sqlstr.ToString(), param);
                tran.Commit();
            }
            catch
            {
                tran.Rollback();
            }
            return(num);
        }
Ejemplo n.º 16
0
        private bool DeleteEmployee(string employeeId)
        {
            TransactionManager transactionManager = null;

            try
            {
                transactionManager = ConnectionScope.CreateTransaction();
                NetTiersProvider dataProvider = ConnectionScope.Current.DataProvider;
                var listAddress = dataProvider.AddressProvider.GetByEmployeeId(int.Parse(employeeId));
                if (listAddress?.Any() == true && dataProvider.AddressProvider.Delete(transactionManager, listAddress) == 0)
                {
                    throw new Exception("An error occurred while deleting Address!");
                }
                var employee = dataProvider.EmployeeProvider.Find($"EmployeeId={employeeId}").FirstOrDefault();
                if (employee != null && !dataProvider.EmployeeProvider.Delete(transactionManager, employee))
                {
                    throw new Exception("An error occurred while deleting Employee!");
                }
                transactionManager.Commit();
            }
            catch (Exception exc)
            {
                if (transactionManager != null && transactionManager.IsOpen)
                {
                    transactionManager.Rollback();
                }
                return(false);
            }
            return(true);
        }
Ejemplo n.º 17
0
        int SendItemByType(NbManagershareEntity shareEntity, List <ConfigMallgiftbagEntity> prizeList)
        {
            if (prizeList.Count <= 0)
            {
                return((int)MessageCode.NbParameterError);
            }
            var mail = new MailBuilder(shareEntity.ManagerId, "分享礼包", 0, prizeList, EnumMailType.Share, 0, 0);

            //    var mail = new MailBuilder(shareEntity.ManagerId, point, coin, itemList, EnumMailType.Share);
            using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
            {
                transactionManager.BeginTransaction();
                var f = true;
                if (!mail.Save(transactionManager.TransactionObject))
                {
                    f = false;
                }

                if (!NbManagershareMgr.Update(shareEntity, transactionManager.TransactionObject))
                {
                    f = false;
                }
                if (f)
                {
                    transactionManager.Commit();
                }
                else
                {
                    transactionManager.Rollback();
                    return((int)MessageCode.Exception);
                }
            }
            return((int)MessageCode.Success);
        }
Ejemplo n.º 18
0
        MessageCode SaveExchange(LadderManagerEntity ladderManager, ItemPackageFrame package, LadderExchangerecordEntity ladderExchangerecord)
        {
            if (ladderManager == null || package == null || ladderExchangerecord == null)
            {
                return(MessageCode.NbUpdateFail);
            }
            try
            {
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    var messageCode = Tran_SaveExchange(transactionManager.TransactionObject, ladderManager, package, ladderExchangerecord);

                    if (messageCode == ShareUtil.SuccessCode)
                    {
                        transactionManager.Commit();
                    }
                    else
                    {
                        transactionManager.Rollback();
                    }
                    return(messageCode);
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("SaveExchange", ex);
                return(MessageCode.Exception);
            }
        }
Ejemplo n.º 19
0
        public bool Excluir(String strSitefStatusID)
        {
            TransactionManager objTransaction = null;

            try
            {
                objTransaction = new TransactionManager(TransactionManager.OpcoesDeDataSource.ServidoDaLojaAtual);
                objTransaction.BeginTransaction();

                this.Excluir(strSitefStatusID, ref objTransaction);

                if (objTransaction != null)
                {
                    objTransaction.Commit();
                }
                return(true);
            }
            catch (Exception)
            {
                if (objTransaction != null)
                {
                    objTransaction.RollBack();
                }
                throw;
            }
        }
Ejemplo n.º 20
0
        public bool Alterar(DataRow dtrAlterar)
        {
            TransactionManager objTransaction = null;

            try
            {
                objTransaction = new TransactionManager(TransactionManager.OpcoesDeDataSource.ServidoDaLojaAtual);
                objTransaction.BeginTransaction();

                this.Alterar(dtrAlterar, ref objTransaction);

                if (objTransaction != null)
                {
                    objTransaction.Commit();
                }

                return(true);
            }
            catch (Exception)
            {
                if (objTransaction != null)
                {
                    objTransaction.RollBack();
                }
                throw;
            }
        }
Ejemplo n.º 21
0
 public MessageCode SaveWincountPrize(NbManagerEntity manager, LeagueWincountrecordEntity leagueWincountRecord, ItemPackageFrame package, int point, int coin)
 {
     try
     {
         using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetConnectionString(EnumDbType.Main)))
         {
             transactionManager.BeginTransaction();
             var messageCode = Tran_SaveWincountPrizePrize(transactionManager.TransactionObject, manager, leagueWincountRecord, package, point, coin);
             if (messageCode == MessageCode.Success)
             {
                 transactionManager.Commit();
             }
             else
             {
                 transactionManager.Rollback();
             }
             return(messageCode);
         }
     }
     catch (Exception ex)
     {
         SystemlogMgr.ErrorByZone("SavePrize", ex);
         return(MessageCode.Exception);
     }
 }
Ejemplo n.º 22
0
        public void Incluir(DataRow dtrIncluir)
        {
            TransactionManager objTransaction = null;

            try
            {
                objTransaction = new TransactionManager(TransactionManager.OpcoesDeDataSource.ServidoDaLojaAtual);
                objTransaction.BeginTransaction();

                this.Incluir(dtrIncluir, ref objTransaction);

                if (objTransaction != null)
                {
                    objTransaction.Commit();
                }
            }
            catch (Exception)
            {
                if (objTransaction != null)
                {
                    objTransaction.RollBack();
                }
                throw;
            }
        }
Ejemplo n.º 23
0
        public static int AddSubBudgetInfo(SubBudgetModel subBudgetModel, XBase.Common.UserInfoUtil userinfo)
        {
            StringBuilder sqlstr = new StringBuilder();

            sqlstr.Append("insert into officedba.SubBudget(CompanyCD,projectid,BudgetName) values(@CompanyCD,@projectid,@BudgetName)");
            SqlParameter[] param =
            {
                new SqlParameter("@CompanyCD",  SqlDbType.VarChar, 50),
                new SqlParameter("@projectid",  SqlDbType.Int),
                new SqlParameter("@BudgetName", SqlDbType.VarChar, 200)
            };
            param[0].Value = userinfo.CompanyCD;
            param[1].Value = subBudgetModel.Projectid;
            param[2].Value = subBudgetModel.BudgetName;

            TransactionManager tran = new TransactionManager();
            int num = 0;

            tran.BeginTransaction();
            try
            {
                num = SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, sqlstr.ToString(), param);
                tran.Commit();
            }
            catch
            {
                tran.Rollback();
            }
            return(num);
        }
Ejemplo n.º 24
0
        public static int Add(XBase.Model.Office.SellReport.UserProductInfo model)
        {
            int                num    = 0;
            string             sqlstr = "insert into officedba.UserProductInfo(CompanyCD,productNum,productName,price,bref,memo) values(@CompanyCD,@productNum,@productName,@price,@bref,@memo)";
            TransactionManager tran   = new TransactionManager();

            tran.BeginTransaction();
            SqlParameter[] param =
            {
                new SqlParameter("@CompanyCD",   SqlDbType.VarChar,   50),
                new SqlParameter("@productNum",  SqlDbType.VarChar,   50),
                new SqlParameter("@productName", SqlDbType.VarChar,  200),
                new SqlParameter("@price",       SqlDbType.Decimal),
                new SqlParameter("@bref",        SqlDbType.VarChar,  500),
                new SqlParameter("@memo",        SqlDbType.VarChar, 1000)
            };
            param[0].Value = model.CompanyCD;
            param[1].Value = model.productNum;
            param[2].Value = model.productName;
            param[3].Value = model.price;
            param[4].Value = model.bref;
            param[5].Value = model.memo;
            try
            {
                num = SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, sqlstr, param);
                tran.Commit();
            }
            catch
            {
                tran.Rollback();
            }
            return(num);
        }
Ejemplo n.º 25
0
        public static int Update(XBase.Model.Office.SellReport.UserProductInfo model)
        {
            int                num    = 0;
            string             sqlstr = "update officedba.UserProductInfo set productNum=@productNum,productName=@productName,price=@price,bref=@bref,memo=@memo where id=@id";
            TransactionManager tran   = new TransactionManager();

            tran.BeginTransaction();
            SqlParameter[] param =
            {
                new SqlParameter("@CompanyCD",   SqlDbType.VarChar,    50),
                new SqlParameter("@productNum",  SqlDbType.VarChar,    50),
                new SqlParameter("@productName", SqlDbType.VarChar,   200),
                new SqlParameter("@price",       SqlDbType.Decimal),
                new SqlParameter("@bref",        SqlDbType.VarChar,   500),
                new SqlParameter("@memo",        SqlDbType.VarChar,  1000),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            param[0].Value = model.CompanyCD;
            param[1].Value = model.productNum;
            param[2].Value = model.productName;
            param[3].Value = model.price;
            param[4].Value = model.bref;
            param[5].Value = model.memo;
            param[6].Value = model.id;
            try
            {
                num = SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, sqlstr, param);
                tran.Commit();
            }
            catch
            {
                tran.Rollback();
            }
            return(num);
        }
Ejemplo n.º 26
0
 public void CommitTransaction()
 {
     if (TransactionManager.Transaction() != null)
     {
         TransactionManager.Commit();
     }
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Attaches the construction prints, passed in as the prints parameter, to the active job.
        /// </summary>
        /// <param name="prints">File path/name of generated construction prints.</param>
        /// <returns>true if successful; else, false</returns>
        private bool AttachConstructionPrints(string prints)
        {
            bool retVal = false;

            try
            {
                IGTApplication   app = GTClassFactory.Create <IGTApplication>();
                AttachWRDocument attachWRDocument = new AttachWRDocument();
                TransactionManager.Begin("Attach Archival Prints");

                if (attachWRDocument.AttachDocument(app.DataContext.ActiveJob, prints, "Work Prints Design"))
                {
                    TransactionManager.Commit();
                    retVal = true;
                }
                else
                {
                    TransactionManager.Rollback();
                }
            }
            catch (Exception ex)
            {
                string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message);
                MessageBox.Show(exMsg, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(retVal);
        }
Ejemplo n.º 28
0
        public void DeletePDCompetencyKSAFactor(long positionCompetencyKSAID, int userId)
        {
            TransactionManager currentTransaction = new TransactionManager(base.CurrentDatabase);

            currentTransaction.BeginTransaction();

            DbCommand commandWrapper = GetDbCommand("spr_DeletePositionCompetencyKSAFactor");

            try
            {
                commandWrapper.Parameters.Add(new SqlParameter("@PositionCompetencyKSAID", positionCompetencyKSAID));
                commandWrapper.Parameters.Add(new SqlParameter("@userId", userId));

                if (currentTransaction != null)
                {
                    DatabaseUtility.ExecuteNonQuery(currentTransaction, commandWrapper);
                }
                else
                {
                    ExecuteNonQuery(commandWrapper);
                }

                currentTransaction.Commit();
            }
            catch (Exception ex)
            {
                currentTransaction.Rollback();
                HandleException(ex);
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 删除回款计划
        /// </summary>
        /// <param name="strIDS"></param>
        /// <returns></returns>
        public static bool DelSellGathering(string strIDS, out string strMsg)
        {
            bool   isSucc = false;//是否添加成功
            string strSql = "delete from officedba.SellGathering where ID = @ID";

            string[] strId = strIDS.Split(',');
            strMsg = "";
            TransactionManager tran = new TransactionManager();

            tran.BeginTransaction();
            try
            {
                for (int i = 0; i < strId.Length; i++)
                {
                    SqlParameter[] para = { new SqlParameter("@ID", Convert.ToInt32(strId[i])) };
                    SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql, para);
                }

                tran.Commit();
                isSucc = true;
                strMsg = "删除成功!";
            }
            catch (Exception ex)
            {
                tran.Rollback();
                strMsg = "删除失败,请联系系统管理员!";
                isSucc = false;
                throw ex;
            }
            return(isSucc);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 删除审批步骤
        /// </summary>
        /// <param name="contractID"></param>
        /// <param name="CurrentEmployee"></param>
        /// <returns></returns>
        public bool DeleteWorkFlowInstance(string WorkFlowInstanceID)
        {
            string methodName = "DeleteWorkFlowInstance";

            Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + MessageType.IN + ":" + string.Format("WorkFlowInstance={0}", WorkFlowInstanceID));

            TransactionManager transaction = DataRepository.Provider.CreateTransaction();

            try
            {
                transaction.BeginTransaction();

                //删除该合同下计价方式
                bool result = DataRepository.WorkFlowInstanceProvider.Delete(transaction, WorkFlowInstanceID);

                transaction.Commit();
                return(true);
            }
            catch (Exception exp)
            {
                transaction.Rollback();
                Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + MessageType.Exception + ":" + string.Format("Exception={0}", exp));
                throw exp;
            }
        }
 private void Instead01(TransactionManager tm, Customer cus)
 {
     MessageBox.Show("Something...");
     // Begin the transaction after the message box,
     // e.g. if you want to prompt them to do something before saving.
     tm.BeginTransaction();
     DataRepository.CustomerProvider.Insert(tm, cus);
     tm.Commit();
 }
 private void Instead02(TransactionManager tm, Customer cus)
 {
     tm.BeginTransaction();
     DataRepository.CustomerProvider.Insert(tm, cus);
     tm.Commit();
     // Or, show the message box after the transaction completed,
     // e.g. to notify them of an event after saving
     MessageBox.Show("Something...");
 }
Ejemplo n.º 33
0
      /// <summary>
      /// Apply a record to placeholders
      /// </summary>
		/// <param name="placeHolders">List of placeholder which should be applied</param>
		/// <param name="recordName">Name of record</param>
		/// <returns>Return true if one or more was applied</returns>
      public static void ApplyRecord(IEnumerable<PlaceHolder> placeHolders, string recordName)
      {
         using (Transaction transaction = new TransactionManager().CreateTransaction())
         {
            foreach (PlaceHolder placeHolder in placeHolders)
            {
               placeHolder.ApplyRecord(recordName, true); // apply (with page data)
               transaction.Commit(); // needed if not placed in project
            }
         }
      }
        // SAMPLE 01
        //
        // As mentioned in "C01_TransactionManager," the idea behind transactions
        // is that it should surround a block of code that either saves everything
        // or nothing.
        //
        // Here is the thing to remember: While the transaction is open it will prevent
        // anything from accessing the database tables that you are busy with. This is
        // to prevent "dirty" or incomplete records.
        //
        // The caveat: you want your transaction to execute as fast as possible. Be
        // like a ninja: get in, do your thing, and get out.
        //
        private void BadlyMisplacedCode(TransactionManager tm, Customer cus)
        {
            tm.BeginTransaction();
            DataRepository.CustomerProvider.Insert(tm, cus);
            MessageBox.Show("Something...");
            tm.Commit();

            // Can you see it?
            // This code will block the Customer table on the entire branch until the user
            // clicks "OK" on the message box. The impact of this is enourmous.
        }
Ejemplo n.º 35
0
      /// <summary>
      /// Create a record to a placeHolder by name and apply a record
      /// </summary>
		/// <param name="placeHolders">List of placeholder which should be applied</param>
		/// <param name="placeHolderName">Name of placeholder</param>
		/// <param name="recordName">Name of record</param>
      /// <param name="variableName">Variable to set</param>
      /// <param name="value">New value of the variable</param>
		/// <returns>Return true if one or more was applied</returns>
      public bool CreateRecordWithValueAndApply(PlaceHolder[] placeHolders, string placeHolderName, string recordName, string variableName, string value)
		{
			List<PlaceHolder> foundPlaceHolder = placeHolders
				.Where(placeHolder => placeHolder.Name.Equals(placeHolderName)) // name
				.ToList();

			foreach (PlaceHolder placeHolder in foundPlaceHolder)
			{
				placeHolder.AddRecord(recordName);
				placeHolder.set_Value(recordName, variableName, value);
				using (Transaction transaction = new TransactionManager().CreateTransaction())
				{
					placeHolder.ApplyRecord(recordName, true); // apply (with page data)
					transaction.Commit(); // needed if not placed in project
				}
			}

			return foundPlaceHolder.Any(); // true == found | false == not found
		}