示例#1
0
 /// <summary>
 /// 获取实体数据
 /// </summary>
 /// <param name='strCondition'>条件(AND Code='11')</param>
 /// <returns>model</returns>
 public Rec_Main GetModel(string strCondition)
 {
     List<Rec_Main> list = instance.GetListByWhere(strCondition);
     Rec_Main model = new Rec_Main();
     if (list != null && list.Count > 0)
     {
         model = list[0];
     }
     else
     {
         model = null;
     }
     return model;
 }
示例#2
0
        /// <summary>
        /// 更新单据主表      没有申请人,部门,时间 Rec_Main对象(即:一条记录
        /// </summary>
        public int Update(Rec_Main rec_Main)
        {
            StringBuilder sbParameter=new StringBuilder();
              StringBuilder sb=new StringBuilder();
              sb.Append(@"UPDATE       Rec_Main       SET ");
            if(rec_Main.RM_Code_IsChanged){sbParameter.Append("RM_Code=@RM_Code, ");}
              if(rec_Main.Module_Code_IsChanged){sbParameter.Append("Module_Code=@Module_Code, ");}
              if(rec_Main.Module_Name_IsChanged){sbParameter.Append("Module_Name=@Module_Name, ");}
              if(rec_Main.RM_Name_IsChanged){sbParameter.Append("RM_Name=@RM_Name, ");}
              if(rec_Main.RM_RefCode_IsChanged){sbParameter.Append("RM_RefCode=@RM_RefCode, ");}
              if(rec_Main.Creator_IsChanged){sbParameter.Append("Creator=@Creator, ");}
              if(rec_Main.CreateTime_IsChanged){sbParameter.Append("CreateTime=@CreateTime, ");}
              if(rec_Main.VerifyStuff_IsChanged){sbParameter.Append("VerifyStuff=@VerifyStuff, ");}
              if(rec_Main.VerifyDate_IsChanged){sbParameter.Append("VerifyDate=@VerifyDate, ");}
              if(rec_Main.VerifyStat_IsChanged){sbParameter.Append("VerifyStat=@VerifyStat, ");}
              if(rec_Main.Stat_IsChanged){sbParameter.Append("Stat=@Stat ");}
          sb.Append(sbParameter.ToString().Trim().TrimEnd(','));
              sb.Append(      " WHERE 1=1 AND ((Stat is null) or (Stat=0))   and RM_ID=@RM_ID; " );
              string sql=sb.ToString();
             if(rec_Main.RM_Code_IsChanged)
             {
             if (string.IsNullOrEmpty(rec_Main.RM_Code))
             {
            idb.AddParameter("@RM_Code", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@RM_Code", rec_Main.RM_Code);
             }
              }
             if(rec_Main.Module_Code_IsChanged)
             {
             if (string.IsNullOrEmpty(rec_Main.Module_Code))
             {
            idb.AddParameter("@Module_Code", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@Module_Code", rec_Main.Module_Code);
             }
              }
             if(rec_Main.Module_Name_IsChanged)
             {
             if (string.IsNullOrEmpty(rec_Main.Module_Name))
             {
            idb.AddParameter("@Module_Name", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@Module_Name", rec_Main.Module_Name);
             }
              }
             if(rec_Main.RM_Name_IsChanged)
             {
             if (string.IsNullOrEmpty(rec_Main.RM_Name))
             {
            idb.AddParameter("@RM_Name", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@RM_Name", rec_Main.RM_Name);
             }
              }
             if(rec_Main.RM_RefCode_IsChanged)
             {
             if (string.IsNullOrEmpty(rec_Main.RM_RefCode))
             {
            idb.AddParameter("@RM_RefCode", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@RM_RefCode", rec_Main.RM_RefCode);
             }
              }
             if(rec_Main.Creator_IsChanged)
             {
             if (string.IsNullOrEmpty(rec_Main.Creator))
             {
            idb.AddParameter("@Creator", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@Creator", rec_Main.Creator);
             }
              }
             if(rec_Main.CreateTime_IsChanged)
             {
             if (rec_Main.CreateTime == DateTime.MinValue)
             {
            idb.AddParameter("@CreateTime", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@CreateTime", rec_Main.CreateTime);
             }
              }
             if(rec_Main.VerifyStuff_IsChanged)
             {
             if (string.IsNullOrEmpty(rec_Main.VerifyStuff))
             {
            idb.AddParameter("@VerifyStuff", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@VerifyStuff", rec_Main.VerifyStuff);
             }
              }
             if(rec_Main.VerifyDate_IsChanged)
             {
             if (rec_Main.VerifyDate == DateTime.MinValue)
             {
            idb.AddParameter("@VerifyDate", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@VerifyDate", rec_Main.VerifyDate);
             }
              }
             if(rec_Main.VerifyStat_IsChanged)
             {
             if (string.IsNullOrEmpty(rec_Main.VerifyStat))
             {
            idb.AddParameter("@VerifyStat", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@VerifyStat", rec_Main.VerifyStat);
             }
              }
             if(rec_Main.Stat_IsChanged)
             {
             if (rec_Main.Stat == 0)
             {
            idb.AddParameter("@Stat", 0);
             }
             else
             {
            idb.AddParameter("@Stat", rec_Main.Stat);
             }
              }

             idb.AddParameter("@RM_ID", rec_Main.RM_ID);

             int Re = 0;
             //SQL日志记录
             var RunMethod = System.Reflection.MethodBase.GetCurrentMethod();
             System.Collections.Hashtable param = new System.Collections.Hashtable();
             string Ex = "0";
             foreach (System.Collections.DictionaryEntry item in idb.GetParameters())
             {
                 param.Add(item.Key, item.Value);
             }
             try
             {
                 Re = idb.ExeCmd(sql);
                 Ex = Re.ToString();
             }
             catch (Exception ex)
             {
                 Ex = ex.Message;
             }

             SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name,Ex);

             return Re;
示例#3
0
 /// <summary>
 /// 获取指定的单据主表      没有申请人,部门,时间 Rec_Main对象集合
 /// </summary>
 public List<Rec_Main> GetListByWhere(string strCondition)
 {
     List<Rec_Main> ret = new List<Rec_Main>();
      string sql = "SELECT  RM_ID,RM_Code,Module_Code,Module_Name,RM_Name,RM_RefCode,Creator,CreateTime,VerifyStuff,VerifyDate,VerifyStat,Stat FROM Rec_Main WHERE 1=1 AND ((Stat is null) or (Stat=0) ) ";
      if(!string.IsNullOrEmpty(strCondition))
      {
     strCondition.Replace('\'','"'); //防sql注入
     sql += strCondition ;
      }
       SqlDataReader dr=null;
        try {
       dr=(SqlDataReader)idb.ReturnReader(sql);
      while(dr.Read())
      {
     Rec_Main rec_Main = new Rec_Main();
     if (dr["RM_ID"] != DBNull.Value) rec_Main.RM_ID = Convert.ToDecimal(dr["RM_ID"]);
     if (dr["RM_Code"] != DBNull.Value) rec_Main.RM_Code = Convert.ToString(dr["RM_Code"]);
     if (dr["Module_Code"] != DBNull.Value) rec_Main.Module_Code = Convert.ToString(dr["Module_Code"]);
     if (dr["Module_Name"] != DBNull.Value) rec_Main.Module_Name = Convert.ToString(dr["Module_Name"]);
     if (dr["RM_Name"] != DBNull.Value) rec_Main.RM_Name = Convert.ToString(dr["RM_Name"]);
     if (dr["RM_RefCode"] != DBNull.Value) rec_Main.RM_RefCode = Convert.ToString(dr["RM_RefCode"]);
     if (dr["Creator"] != DBNull.Value) rec_Main.Creator = Convert.ToString(dr["Creator"]);
     if (dr["CreateTime"] != DBNull.Value) rec_Main.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
     if (dr["VerifyStuff"] != DBNull.Value) rec_Main.VerifyStuff = Convert.ToString(dr["VerifyStuff"]);
     if (dr["VerifyDate"] != DBNull.Value) rec_Main.VerifyDate = Convert.ToDateTime(dr["VerifyDate"]);
     if (dr["VerifyStat"] != DBNull.Value) rec_Main.VerifyStat = Convert.ToString(dr["VerifyStat"]);
     if (dr["Stat"] != DBNull.Value) rec_Main.Stat = Convert.ToInt32(dr["Stat"]);
     ret.Add(rec_Main);
      }
       }catch (System.Exception ex){ throw ex; }  finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); }   }
      return ret;
 }
示例#4
0
        /// <summary>
        /// 获取指定的单据主表      没有申请人,部门,时间 Rec_Main对象(即:一条记录
        /// </summary>
        public Rec_Main GetByKey(decimal rM_ID)
        {
            Rec_Main rec_Main = new Rec_Main();
             string sql = "SELECT  RM_ID,RM_Code,Module_Code,Module_Name,RM_Name,RM_RefCode,Creator,CreateTime,VerifyStuff,VerifyDate,VerifyStat,Stat FROM Rec_Main WHERE 1=1 AND ((Stat is null) or (Stat=0) )  AND RM_ID=@RM_ID ";
             idb.AddParameter("@RM_ID", rM_ID);

              SqlDataReader dr=null;
               try {
              dr=(SqlDataReader)idb.ReturnReader(sql);
             while(dr.Read())
             {
            if (dr["RM_ID"] != DBNull.Value) rec_Main.RM_ID = Convert.ToDecimal(dr["RM_ID"]);
            if (dr["RM_Code"] != DBNull.Value) rec_Main.RM_Code = Convert.ToString(dr["RM_Code"]);
            if (dr["Module_Code"] != DBNull.Value) rec_Main.Module_Code = Convert.ToString(dr["Module_Code"]);
            if (dr["Module_Name"] != DBNull.Value) rec_Main.Module_Name = Convert.ToString(dr["Module_Name"]);
            if (dr["RM_Name"] != DBNull.Value) rec_Main.RM_Name = Convert.ToString(dr["RM_Name"]);
            if (dr["RM_RefCode"] != DBNull.Value) rec_Main.RM_RefCode = Convert.ToString(dr["RM_RefCode"]);
            if (dr["Creator"] != DBNull.Value) rec_Main.Creator = Convert.ToString(dr["Creator"]);
            if (dr["CreateTime"] != DBNull.Value) rec_Main.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
            if (dr["VerifyStuff"] != DBNull.Value) rec_Main.VerifyStuff = Convert.ToString(dr["VerifyStuff"]);
            if (dr["VerifyDate"] != DBNull.Value) rec_Main.VerifyDate = Convert.ToDateTime(dr["VerifyDate"]);
            if (dr["VerifyStat"] != DBNull.Value) rec_Main.VerifyStat = Convert.ToString(dr["VerifyStat"]);
            if (dr["Stat"] != DBNull.Value) rec_Main.Stat = Convert.ToInt32(dr["Stat"]);
             }
              }catch (System.Exception ex){ throw ex; }  finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); }   }
             return rec_Main;
        }
示例#5
0
 /// <summary>
 /// 获取所有的单据主表      没有申请人,部门,时间 Rec_Main对象(即:一条记录
 /// </summary>
 public List<Rec_Main> GetAll()
 {
     List<Rec_Main> ret = new List<Rec_Main>();
      string sql = "SELECT  RM_ID,RM_Code,Module_Code,Module_Name,RM_Name,RM_RefCode,Creator,CreateTime,VerifyStuff,VerifyDate,VerifyStat,Stat FROM Rec_Main where 1=1 AND ((Stat is null) or (Stat=0) ) order by RM_ID desc ";
       SqlDataReader dr=null;
        try {
       dr=(SqlDataReader)idb.ReturnReader(sql);
      while(dr.Read())
      {
     Rec_Main rec_Main = new Rec_Main();
     if (dr["RM_ID"] != DBNull.Value) rec_Main.RM_ID = Convert.ToDecimal(dr["RM_ID"]);
     if (dr["RM_Code"] != DBNull.Value) rec_Main.RM_Code = Convert.ToString(dr["RM_Code"]);
     if (dr["Module_Code"] != DBNull.Value) rec_Main.Module_Code = Convert.ToString(dr["Module_Code"]);
     if (dr["Module_Name"] != DBNull.Value) rec_Main.Module_Name = Convert.ToString(dr["Module_Name"]);
     if (dr["RM_Name"] != DBNull.Value) rec_Main.RM_Name = Convert.ToString(dr["RM_Name"]);
     if (dr["RM_RefCode"] != DBNull.Value) rec_Main.RM_RefCode = Convert.ToString(dr["RM_RefCode"]);
     if (dr["Creator"] != DBNull.Value) rec_Main.Creator = Convert.ToString(dr["Creator"]);
     if (dr["CreateTime"] != DBNull.Value) rec_Main.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
     if (dr["VerifyStuff"] != DBNull.Value) rec_Main.VerifyStuff = Convert.ToString(dr["VerifyStuff"]);
     if (dr["VerifyDate"] != DBNull.Value) rec_Main.VerifyDate = Convert.ToDateTime(dr["VerifyDate"]);
     if (dr["VerifyStat"] != DBNull.Value) rec_Main.VerifyStat = Convert.ToString(dr["VerifyStat"]);
     if (dr["Stat"] != DBNull.Value) rec_Main.Stat = Convert.ToInt32(dr["Stat"]);
     ret.Add(rec_Main);
      }
       }catch (System.Exception ex){ throw ex; }  finally {  if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); }   }
      return ret;
 }
示例#6
0
        /// <summary>
        /// 添加单据主表      没有申请人,部门,时间 Rec_Main对象(即:一条记录)
        /// </summary>
        public int Add(Rec_Main rec_Main)
        {
            string sql = "INSERT INTO Rec_Main (RM_Code,Module_Code,Module_Name,RM_Name,RM_RefCode,Creator,CreateTime,VerifyStuff,VerifyDate,VerifyStat,Stat) VALUES (@RM_Code,@Module_Code,@Module_Name,@RM_Name,@RM_RefCode,@Creator,@CreateTime,@VerifyStuff,@VerifyDate,@VerifyStat,@Stat)";
             if (string.IsNullOrEmpty(rec_Main.RM_Code))
             {
            idb.AddParameter("@RM_Code", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@RM_Code", rec_Main.RM_Code);
             }
             if (string.IsNullOrEmpty(rec_Main.Module_Code))
             {
            idb.AddParameter("@Module_Code", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@Module_Code", rec_Main.Module_Code);
             }
             if (string.IsNullOrEmpty(rec_Main.Module_Name))
             {
            idb.AddParameter("@Module_Name", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@Module_Name", rec_Main.Module_Name);
             }
             if (string.IsNullOrEmpty(rec_Main.RM_Name))
             {
            idb.AddParameter("@RM_Name", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@RM_Name", rec_Main.RM_Name);
             }
             if (string.IsNullOrEmpty(rec_Main.RM_RefCode))
             {
            idb.AddParameter("@RM_RefCode", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@RM_RefCode", rec_Main.RM_RefCode);
             }
             if (string.IsNullOrEmpty(rec_Main.Creator))
             {
            idb.AddParameter("@Creator", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@Creator", rec_Main.Creator);
             }
             if (rec_Main.CreateTime == DateTime.MinValue)
             {
            idb.AddParameter("@CreateTime", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@CreateTime", rec_Main.CreateTime);
             }
             if (string.IsNullOrEmpty(rec_Main.VerifyStuff))
             {
            idb.AddParameter("@VerifyStuff", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@VerifyStuff", rec_Main.VerifyStuff);
             }
             if (rec_Main.VerifyDate == DateTime.MinValue)
             {
            idb.AddParameter("@VerifyDate", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@VerifyDate", rec_Main.VerifyDate);
             }
             if (string.IsNullOrEmpty(rec_Main.VerifyStat))
             {
            idb.AddParameter("@VerifyStat", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@VerifyStat", rec_Main.VerifyStat);
             }
             if (rec_Main.Stat == 0)
             {
            idb.AddParameter("@Stat", 0);
             }
             else
             {
            idb.AddParameter("@Stat", rec_Main.Stat);
             }

             int Re = 0;
             //SQL日志记录
             var RunMethod = System.Reflection.MethodBase.GetCurrentMethod();
             System.Collections.Hashtable param = new System.Collections.Hashtable();
             string Ex = "0";
             foreach (System.Collections.DictionaryEntry item in idb.GetParameters())
             {
                 param.Add(item.Key, item.Value);
             }
             try
             {
                 Re = idb.ExeCmd(sql);
                 Ex = Re.ToString();
             }
             catch (Exception ex)
             {
                 Ex = ex.Message;
             }

             SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name,Ex);

             return Re;
        }
示例#7
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name='model'>实体</param>
 /// <returns>bool</returns>
 public bool Update(Rec_Main model,bool IsValid)
 {
     bool result = false;
     var e = new ModelExceptions();
     if(e.IsValid && IsValid){
         int _rseult = instance.Update(model);
         if (_rseult > 0)
         {
             result = true;
         }
     }
     return result;
 }
示例#8
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name='model'>实体</param>
 /// <param name='model'>是否完成验证</param>
 /// <returns>bool</returns>
 public bool Insert(Rec_Main model,bool IsValid)
 {
     var e = new ModelExceptions();
     bool result = false;
     if (e.IsValid && IsValid)
     {
         //完成了验证,开始更新数据库了
         int _result = instance.Add(model);
         if (_result > 0)
         {
             result = true;
         }
     }
     return result;
 }
示例#9
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <returns>bool</returns>
        public bool Insert(Rec_Main model)
        {
            bool result = false;
            try
            {
                int _result = instance.Add(model);
                if (_result > 0)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return result;
        }