Ejemplo n.º 1
0
        public bool LinksRemoveDown(int id)
        {
            //当前对象
            Links current = Gateway.Default.From <Links>().Where(Links._.Lk_Id == id).ToFirst <Links>();
            //当前对象父节点id;
            int lsId = (int)current.Ls_Id;
            //当前对象排序号
            int orderValue = (int)current.Lk_Tax;
            //下一个对象,即弟弟对象;弟弟不存则直接返回false;
            Links next = Gateway.Default.From <Links>()
                         .Where(Links._.Lk_Tax > orderValue && Links._.Org_ID == current.Org_ID && Links._.Ls_Id == lsId)
                         .OrderBy(Links._.Lk_Tax.Asc).ToFirst <Links>();

            if (next == null)
            {
                //如果弟对象不存在,则表示当前节点在兄弟中是老幺;即是最底端;
                return(false);
            }
            //交换排序号
            current.Lk_Tax = next.Lk_Tax;
            next.Lk_Tax    = orderValue;
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Save <Links>(current);
                    tran.Save <Links>(next);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改排序
        /// </summary>
        /// <param name="xml"></param>
        public void SaveOrder(string xml)
        {
            XmlDocument resXml = new XmlDocument();

            resXml.XmlResolver = null;
            using (DbTrans tran = Gateway.Default.BeginTrans())
                try
                {
                    resXml.LoadXml(xml, false);
                    XmlNodeList nodeList = resXml.SelectSingleNode("nodes").ChildNodes;
                    //取rootid
                    XmlNode    nodes   = resXml.SelectSingleNode("nodes");
                    XmlElement xenodes = (XmlElement)nodes;
                    //遍历所有子节点
                    foreach (XmlNode xn in nodeList)
                    {
                        XmlElement xe               = (XmlElement)xn;
                        int        id               = Convert.ToInt32(xe.Attributes["id"].Value);
                        int        pid              = Convert.ToInt32(xe.Attributes["pid"].Value);
                        int        tax              = Convert.ToInt32(xe.Attributes["tax"].Value);
                        bool       state            = Convert.ToBoolean(xe.Attributes["state"].Value);
                        Song.Entities.ManageMenu mm = this.GetSingle(id);
                        if (mm != null)
                        {
                            mm.MM_PatId = pid.ToString();
                            mm.MM_Tax   = tax;
                            tran.Save <ManageMenu>(mm);
                        }
                    }
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
            finally
            {
                tran.Close();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 新增数据
        /// </summary>
        public AjaxResult Insert(TbMonthCostHeSuan model, TbMonthCostHeSuanIncome incomeModel, List <TbMonthCostHeSuanCost> costModel, List <TbMonthCostHeSuanOtherCost> otherCostModel)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            //判断信息是否存在
            var anyRet = AnyInfoType(model.HeSuanMonth, model.ProcessFactoryCode, model.HeSuanCode);

            if (anyRet.state.ToString() != ResultType.success.ToString())
            {
                return(anyRet);
            }
            model.InsertUserCode = OperatorProvider.Provider.CurrentUser.UserCode;
            try
            {
                using (DbTrans trans = Db.Context.BeginTransaction())
                {
                    //添加信息
                    Repository <TbMonthCostHeSuan> .Insert(trans, model);

                    //添加信息
                    Repository <TbMonthCostHeSuanIncome> .Insert(trans, incomeModel);

                    //添加明细信息
                    Repository <TbMonthCostHeSuanCost> .Insert(trans, costModel);

                    if (otherCostModel.Count > 0)
                    {
                        //添加明细信息
                        Repository <TbMonthCostHeSuanOtherCost> .Insert(trans, otherCostModel);
                    }
                    trans.Commit();
                    return(AjaxResult.Success());
                }
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error(ex.ToString()));
            }
        }
Ejemplo n.º 4
0
 public void SaveOrder(string xml)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             XmlDocument resXml = new XmlDocument();
             resXml.XmlResolver = null;
             resXml.LoadXml(xml, false);
             XmlNodeList nodeList = resXml.SelectSingleNode("nodes").ChildNodes;
             //取rootid
             XmlNode    nodes   = resXml.SelectSingleNode("nodes");
             XmlElement xenodes = (XmlElement)nodes;
             //遍历所有子节点
             foreach (XmlNode xn in nodeList)
             {
                 XmlElement            xe  = (XmlElement)xn;
                 int                   id  = Convert.ToInt32(xe.Attributes["id"].Value);
                 int                   pid = Convert.ToInt32(xe.Attributes["pid"].Value);
                 int                   tax = Convert.ToInt32(xe.Attributes["tax"].Value);
                 Song.Entities.Columns nc  = this.Single(id);
                 if (nc != null)
                 {
                     nc.Col_PID = pid;
                     nc.Col_Tax = tax;
                     tran.Save <Columns>(nc);
                 }
             }
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 5
0
 /// <suPsary>
 /// 修改
 /// </suPsary>
 /// <param name="entity">业务实体</param>
 public void SortSave(LinksSort entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <LinksSort>(entity);
             tran.Update <Links>(new Field[] { Links._.Ls_Name }, new object[] { entity.Ls_Name }, Links._.Ls_Id == entity.Ls_Id);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void DownloadTypeSave(DownloadType entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <DownloadType>(entity);
             tran.Update <Download>(new Field[] { Download._.Dty_Type }, new object[] { entity.Dty_Name }, Download._.Dty_Id == entity.Dty_Id);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void TitleSave(EmpTitle entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <EmpTitle>(entity);
             tran.Update <EmpAccount>(new Field[] { EmpAccount._.Title_Name }, new object[] { entity.Title_Name }, EmpAccount._.Title_Id == entity.Title_Id);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 8
0
 public void SpecialDelete(int identify)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <Special>(Special._.Sp_Id == identify);
             tran.Delete <Special_Article>(Special_Article._.Sp_Id == identify);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 9
0
 public void ProductDelete(int identify)
 {
     Song.Entities.Product entity = this.ProductSingle(identify);
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             _ProductDelete(entity, tran);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 10
0
 /// <suPsary>
 /// 删除
 /// </suPsary>
 /// <param name="entity">业务实体</param>
 public void SortDelete(LinksSort entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <LinksSort>(LinksSort._.Ls_Id == entity.Ls_Id);
             tran.Delete <Links>(Links._.Ls_Id == entity.Ls_Id);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 11
0
 public void PictureSetCover(string uid, int pid)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
         try
         {
             //去除当前相册的封面
             tran.Update <Picture>(new Field[] { Picture._.Pic_IsCover }, new object[] { false }, Picture._.Pic_Uid == uid);
             //设置当前图片封面
             tran.Update <Picture>(new Field[] { Picture._.Pic_IsCover }, new object[] { true }, Picture._.Pic_Id == pid);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
     finally
     {
         tran.Close();
     }
 }
Ejemplo n.º 12
0
 public void TrpDelete(string uid)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <ExamGroup>(ExamGroup._.Exam_UID == uid);
             tran.Delete <TrPlan>(TrPlan._.TrP_UID == uid);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
 /// <summary>
 /// 删除,按主键ID;
 /// </summary>
 /// <param name="identify">实体的主键</param>
 public void ThemeDelete(int identify)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <ProfitSharing>(ProfitSharing._.Ps_ID == identify);
             tran.Delete <ProfitSharing>(ProfitSharing._.Ps_PID == identify);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 创建人:李沈杰
        /// 描    述:修改密码
        /// </summary>
        /// <param name="UserID">用户名</param>
        /// <returns></returns>
        public bool UpdateProjectInfo(string UserID, string UserPassword)
        {
            ProjectInfo opjson = new ProjectInfo();

            opjson.UserPassword = UserPassword;
            //事务定义执行
            DbTrans trans = DB_Conn1.Context.BeginTransaction();

            try
            {
                DB_Conn1.Context.Update(trans, opjson, ProjectInfo._.UserID == UserID);

                trans.Commit();
                return(true);
            }
            catch
            {
                trans.Rollback();
                return(false);
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void SortSave(AddressSort entity)
 {
     using (DbTrans trans = Gateway.Default.BeginTrans())
     {
         try
         {
             trans.Save <AddressSort>(entity);
             trans.Update <AddressList>(new Field[] { AddressList._.Ads_Name }, new object[] { entity.Ads_Name }, AddressList._.Ads_Id == entity.Ads_Id);
             trans.Commit();
         }
         catch
         {
             trans.Rollback();
             throw;
         }
         finally
         {
             trans.Close();
         }
     }
 }
Ejemplo n.º 16
0
 public int RootDelete(int identify)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             this._Delete(identify, tran);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
     return(identify);
 }
Ejemplo n.º 17
0
 public void SortSetDefault(int orgid, int identify)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Update <TeacherSort>(new Field[] { TeacherSort._.Ths_IsDefault }, new object[] { false }, TeacherSort._.Org_ID == orgid);
             tran.Update <TeacherSort>(new Field[] { TeacherSort._.Ths_IsDefault }, new object[] { true }, TeacherSort._.Ths_ID == identify);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 18
0
        public void SortSave(KnowledgeSort entity)
        {
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Save <KnowledgeSort>(entity);
                    tran.Update <Knowledge>(new Field[] { Knowledge._.Kns_Name }, new object[] { entity.Kns_Name }, Knowledge._.Kns_ID == entity.Kns_ID);

                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
Ejemplo n.º 19
0
        public AjaxResult Insert(IEnumerable <TbFlowNode> list)
        {
            DbTrans trans = null;

            try
            {
                using (trans = Db.Context.BeginTransaction())
                {
                    FlowNodeDA.Insert(trans, list);
                    trans.Commit();
                    return(AjaxResult.Success());
                }
            }
            catch (Exception)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                return(AjaxResult.Error());
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 将当前栏目向下移动;仅在当前对象的同层移动,即同一父节点下的对象之间移动;
        /// </summary>
        /// <param name="id"></param>
        /// <returns>如果已经处于最底端,则返回false;移动成功,返回true</returns>
        public bool RemoveDown(int id)
        {
            //当前对象
            ManageMenu current = Gateway.Default.From <ManageMenu>().Where(ManageMenu._.MM_Id == id).ToFirst <ManageMenu>();
            //当前对象父节点id;
            string parentId = (string)current.MM_PatId;
            //当前对象排序号
            int orderValue = (int)current.MM_Tax;
            //下一个对象,即弟弟对象;
            ManageMenu down = Gateway.Default.From <ManageMenu>().Where(ManageMenu._.MM_PatId == parentId && ManageMenu._.MM_Tax > orderValue).OrderBy(ManageMenu._.MM_Tax.Asc).ToFirst <ManageMenu>();

            if (down == null)
            {
                //如果弟对象不存在,则表示当前节点在兄弟中是老幺;即是最底端;
                return(false);
            }
            //交换排序号
            current.MM_Tax = down.MM_Tax;
            down.MM_Tax    = orderValue;
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Save <ManageMenu>(current);
                    tran.Save <ManageMenu>(down);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
            return(true);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 将当前栏目向上移动;仅在当前对象的同层移动,即同一父节点下的对象之间移动;
        /// </summary>
        /// <param name="id"></param>
        /// <returns>如果已经处于顶端,则返回false;移动成功,返回true</returns>
        public bool RemoveUp(int id)
        {
            //当前对象
            ManageMenu current = Gateway.Default.From <ManageMenu>().Where(ManageMenu._.MM_Id == id).ToFirst <ManageMenu>();
            //当前对象父节点id;
            string parentId = (string)current.MM_PatId;
            //当前对象排序号
            int orderValue = (int)current.MM_Tax;
            //上一个对象,即兄长对象;
            ManageMenu up = Gateway.Default.From <ManageMenu>().Where(ManageMenu._.MM_PatId == parentId && ManageMenu._.MM_Tax < orderValue).OrderBy(ManageMenu._.MM_Tax.Desc).ToFirst <ManageMenu>();

            if (up == null)
            {
                //如果兄长对象不存在,则表示当前节点在兄弟中是老大;即是最顶点;
                return(false);
            }
            //交换排序号
            current.MM_Tax = up.MM_Tax;
            up.MM_Tax      = orderValue;
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Save <ManageMenu>(current);
                    tran.Save <ManageMenu>(up);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
            return(true);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 修改数据
        /// </summary>
        public AjaxResult Update(TbShortMessageTemplate model)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            try
            {
                using (DbTrans trans = Db.Context.BeginTransaction())//使用事务
                {
                    //修改信息
                    Repository <TbShortMessageTemplate> .Update(trans, model, p => p.ID == model.ID);

                    trans.Commit();//提交事务
                    return(AjaxResult.Success());
                }
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error(ex.ToString()));
            }
        }
Ejemplo n.º 23
0
 public void SaveGroup(UserGroup entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <UserGroup>(entity);
             //修改用户信息中的组名称
             tran.Update <User>(new Field[] { User._.UGrp_Name }, new object[] { entity.UGrp_Name }, User._.UGrp_Id == entity.UGrp_Id);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 24
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void Save(Position entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Save <Position>(entity);
             tran.Update <EmpAccount>(new Field[] { EmpAccount._.Posi_Name },
                                      new object[] { entity.Posi_Name }, EmpAccount._.Posi_Id == entity.Posi_Id);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Ejemplo n.º 25
0
        public bool LinksRemoveUp(int id)
        {
            //当前对象
            Links current = Gateway.Default.From <Links>().Where(Links._.Lk_Id == id).ToFirst <Links>();
            //当前对象父节点id;
            int lsId = (int)current.Ls_Id;
            //当前对象排序号
            int orderValue = (int)current.Lk_Tax;
            //上一个对象,即兄长对象;
            Links up = Gateway.Default.From <Links>().Where(Links._.Org_ID == current.Org_ID && Links._.Ls_Id == lsId && Links._.Lk_Tax < orderValue).OrderBy(Links._.Lk_Tax.Desc).ToFirst <Links>();

            if (up == null)
            {
                //如果兄长对象不存在,则表示当前节点在兄弟中是老大;即是最顶点;
                return(false);
            }
            //交换排序号
            current.Lk_Tax = up.Lk_Tax;
            up.Lk_Tax      = orderValue;
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Save <Links>(current);
                    tran.Save <Links>(up);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
            return(true);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 新增数据
        /// </summary>
        public AjaxResult Insert(List <TbRawMaterialStockRecord> model)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            try
            {
                using (DbTrans trans = Db.Context.BeginTransaction())
                {
                    //添加信息
                    Repository <TbRawMaterialStockRecord> .Insert(trans, model);

                    trans.Commit();
                    return(AjaxResult.Success());
                }
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error(ex.ToString()));
            }
        }
Ejemplo n.º 27
0
        public int AddNodeUI(List <TbFlowNodeUI> list)
        {
            DbTrans trans = null;

            try
            {
                using (trans = Db.Context.BeginTransaction())
                {
                    FlowNodeUIDA.Insert(list);
                    trans.Commit();
                    return(1);
                }
            }
            catch (Exception)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                return(0);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 新增部门信息数据
        /// </summary>
        public AjaxResult InsertNew(List <TbDepartment> dep, bool isApi = false)
        {
            try
            {
                List <TbDepartment> data = Db.Context.From <TbDepartment>().Select(TbDepartment._.All).ToList();
                using (DbTrans trans = Db.Context.BeginTransaction())
                {
                    //先删除原来的表
                    Db.Context.FromSql("truncate table TbDepartment").SetDbTransaction(trans).ExecuteNonQuery();
                    //插入从BM那边取过来的数据
                    Repository <TbDepartment> .Insert(trans, dep, isApi);

                    trans.Commit();//提交事务
                    return(AjaxResult.Success());
                }
            }
            catch (Exception e)
            {
                var err = e.ToString();
                return(AjaxResult.Error(err));
            }
        }
Ejemplo n.º 29
0
        public bool SortRemoveDown(int orgid, int id)
        {
            //当前对象
            TeacherSort current = Gateway.Default.From <TeacherSort>().Where(TeacherSort._.Ths_ID == id).ToFirst <TeacherSort>();
            //当前对象排序号
            int orderValue = (int)current.Ths_Tax;
            //下一个对象,即弟弟对象;
            TeacherSort down = Gateway.Default.From <TeacherSort>()
                               .Where(TeacherSort._.Org_ID == orgid && TeacherSort._.Ths_Tax > orderValue)
                               .OrderBy(TeacherSort._.Ths_Tax.Asc).ToFirst <TeacherSort>();

            if (down == null)
            {
                return(false);
            }
            //交换排序号
            current.Ths_Tax = down.Ths_Tax;
            down.Ths_Tax    = orderValue;
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Save <TeacherSort>(current);
                    tran.Save <TeacherSort>(down);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
            return(true);
        }
Ejemplo n.º 30
0
 /// <summary>
 /// 修改充值码设置项
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void RechargeSetSave(RechargeSet entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             Song.Entities.RechargeSet rs = tran.From <RechargeSet>().Where(RechargeSet._.Rs_ID == entity.Rs_ID).ToFirst <RechargeSet>();
             //如果新增了充值码
             if (rs.Rs_Count < entity.Rs_Count)
             {
                 _RechargeCodeBuilds(entity, entity.Rs_Count - rs.Rs_Count);
             }
             //如果减少的充值码
             if (rs.Rs_Count > entity.Rs_Count)
             {
                 Song.Entities.RechargeCode[] rcs = tran.From <RechargeCode>().Where(RechargeCode._.Rs_ID == entity.Rs_ID && RechargeCode._.Rc_IsUsed == false).ToArray <RechargeCode>(rs.Rs_Count - entity.Rs_Count);
                 foreach (RechargeCode r in rcs)
                 {
                     tran.Delete <RechargeCode>(r);
                 }
             }
             tran.Update <RechargeCode>(new Field[] { RechargeCode._.Rc_Price, RechargeCode._.Rc_LimitStart, RechargeCode._.Rc_LimitEnd },
                                        new object[] { entity.Rs_Price, entity.Rs_LimitStart, entity.Rs_LimitEnd },
                                        RechargeCode._.Rs_ID == entity.Rs_ID && RechargeCode._.Rc_IsUsed == false);
             tran.Save <RechargeSet>(entity);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }