コード例 #1
0
ファイル: WHRule.cs プロジェクト: zhp-apeng/HTMLTERP
 /// <summary>
 /// 新增(传入事务处理)
 /// </summary>
 /// <param name="p_BE">要新增的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         WH     entity  = (WH)p_BE;
         WHCtl  control = new WHCtl(sqlTrans);
         string sql     = string.Empty;
         sql = " SELECT 1 FROM  WH_WH WHERE WHID= " + SysString.ToDBString(entity.WHID);
         if (sqlTrans.Fill(sql).Rows.Count != 0)
         {
             throw new Exception("仓库编码已经存在,请重新输入!");
         }
         sql = " SELECT 1 FROM  WH_WH WHERE WHNM= " + SysString.ToDBString(entity.WHNM);
         if (sqlTrans.Fill(sql).Rows.Count != 0)
         {
             throw new Exception("仓库名称已经存在,请重新输入!");
         }
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.WH_WH, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
コード例 #2
0
ファイル: WHRule.cs プロジェクト: zhp-apeng/HTMLTERP
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_BE">要修改的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RUpdate(BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                WH      entity  = (WH)p_BE;
                Section entity2 = new Section(sqlTrans);
                entity2.MainID = entity.ID;
                entity2.SelectByID();
                string sql = string.Empty;

                sql  = " SELECT 1 FROM  WH_WH WHERE WHID= " + SysString.ToDBString(entity.WHID);
                sql += " AND ID <>" + entity.ID;
                if (sqlTrans.Fill(sql).Rows.Count != 0)
                {
                    throw new Exception("仓库编码已经存在,请重新输入!");
                }
                sql  = " SELECT 1 FROM  WH_WH WHERE WHNM= " + SysString.ToDBString(entity.WHNM);
                sql += " AND ID <>" + entity.ID;
                if (sqlTrans.Fill(sql).Rows.Count != 0)
                {
                    throw new Exception("仓库名称已经存在,请重新输入!");
                }
                //sql = "SELECT 1 FROM WH_Section WHERE MainID=" + entity.ID.ToString();
                //sql += " AND SectionID=" + SysString.ToDBString(entity2.SectionID);
                //if (sqlTrans.Fill(sql).Rows.Count != 0)
                //{
                //    throw new Exception("区编号已经存在,请重新输入!");
                //}
                WHCtl control = new WHCtl(sqlTrans);
                control.Update(entity);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
コード例 #3
0
ファイル: WHRule.cs プロジェクト: zhp-apeng/HTMLTERP
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_BE">要删除的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                WH    entity  = (WH)p_BE;
                WHCtl control = new WHCtl(sqlTrans);


                string sql = "DELETE FROM WH_Section WHERE MainID=" + entity.ID.ToString();
                sqlTrans.ExecuteNonQuery(sql);//删除原单据明细数据

                control.Delete(entity);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }