Exemple #1
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                PayMethod entity = (PayMethod)p_BE;
                string    sql    = "SELECT * FROM Data_PayMethod WHERE ID=" + SysString.ToDBString(entity.ID);
                DataTable dt     = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("ID已存在,请检查后重新输入!");
                }
                sql = "SELECT * FROM Data_PayMethod WHERE Code=" + SysString.ToDBString(entity.Code);
                dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("付款方式编码已存在,请检查后重新输入!");
                }
                sql = "SELECT * FROM Data_PayMethod WHERE Name=" + SysString.ToDBString(entity.Name);
                dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("付款方式的名称已存在,请检查后重新输入!");
                }
                PayMethodCtl control = new PayMethodCtl(sqlTrans);
                //entity.ID=(int)EntityIDTable.GetID((long)SysEntity.Data_PayMethod,sqlTrans);
                control.AddNew(entity);

                for (int i = 0; i < p_BE2.Length; i++)
                {
                    PayMethodDtsRule rule      = new PayMethodDtsRule();
                    PayMethodDts     entityDts = (PayMethodDts)p_BE2[i];
                    entityDts.MainID = entity.ID;
                    entityDts.Seq    = i + 1;
                    rule.RAdd(entityDts, sqlTrans);
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Exemple #2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_BE">要修改的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RUpdate(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                PayMethod entity = (PayMethod)p_BE;
                string    sql    = "SELECT * FROM Data_PayMethod WHERE Code=" + SysString.ToDBString(entity.Code) + " AND ID<>" + entity.ID;
                DataTable dt     = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("付款方式编码已存在,请检查后重新输入!");
                }
                sql = "SELECT * FROM Data_PayMethod WHERE Name=" + SysString.ToDBString(entity.Name) + " AND ID<>" + entity.ID;
                dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("付款方式的名称已存在,请检查后重新输入!");
                }
                PayMethodCtl control = new PayMethodCtl(sqlTrans);
                control.Update(entity);

                sql = "DELETE Data_PayMethodDts WHERE MainID=" + SysString.ToDBString(entity.ID);
                sqlTrans.ExecuteNonQuery(sql);

                for (int i = 0; i < p_BE2.Length; i++)
                {
                    PayMethodDtsRule rule      = new PayMethodDtsRule();
                    PayMethodDts     entityDts = (PayMethodDts)p_BE2[i];
                    entityDts.MainID = entity.ID;
                    entityDts.Seq    = i + 1;
                    rule.RAdd(entityDts, sqlTrans);
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }