示例#1
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <returns>bool</returns>
        public bool Update(PCD_Queue model)
        {
            bool result  = false;
            var  e       = new ModelExceptions();
            int  _rseult = instance.Update(model);

            if (_rseult > 0)
            {
                result = true;
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 获取指定的PCD_Queue对象集合
        /// </summary>
        public List <PCD_Queue> GetListByWhere(string strCondition)
        {
            List <PCD_Queue> ret = new List <PCD_Queue>();
            string           sql = "SELECT  PCDO_ID,PCDO_PlanCode,PCDO_NCode,PCDO_Order,Stat FROM PCD_Queue 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())
                {
                    PCD_Queue pCD_Queue = new PCD_Queue();
                    if (dr["PCDO_ID"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_ID = Convert.ToInt64(dr["PCDO_ID"]);
                    }
                    if (dr["PCDO_PlanCode"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_PlanCode = Convert.ToString(dr["PCDO_PlanCode"]);
                    }
                    if (dr["PCDO_NCode"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_NCode = Convert.ToString(dr["PCDO_NCode"]);
                    }
                    if (dr["PCDO_Order"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_Order = Convert.ToInt32(dr["PCDO_Order"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        pCD_Queue.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                    ret.Add(pCD_Queue);
                }
            }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);
        }
示例#3
0
        /// <summary>
        /// 获取实体数据
        /// </summary>
        /// <param name='strCondition'>条件(AND Code='11')</param>
        /// <returns>model</returns>
        public PCD_Queue GetModel(string strCondition)
        {
            List <PCD_Queue> list  = instance.GetListByWhere(strCondition);
            PCD_Queue        model = new PCD_Queue();

            if (list != null && list.Count > 0)
            {
                model = list[0];
            }
            else
            {
                model = null;
            }
            return(model);
        }
示例#4
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <param name='model'>是否完成验证</param>
        /// <returns>bool</returns>
        public bool Insert(PCD_Queue 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);
        }
示例#5
0
        /// <summary>
        /// 逻辑删除数据
        /// </summary>
        /// <param name='model'>model</param>
        /// <returns>bool</returns>
        public bool Delete(string Condition)
        {
            bool             result = false;
            List <PCD_Queue> list   = instance.GetListByWhere(Condition);

            if (list.Count > 0)
            {
                PCD_Queue model = list[0];
                model.Stat = 1;
                int _rseult = instance.Update(model);
                if (_rseult > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
示例#6
0
        /// <summary>
        /// 获取指定的PCD_Queue对象(即:一条记录
        /// </summary>
        public PCD_Queue GetByKey(Int64 pCDO_ID)
        {
            PCD_Queue pCD_Queue = new PCD_Queue();
            string    sql       = "SELECT  PCDO_ID,PCDO_PlanCode,PCDO_NCode,PCDO_Order,Stat FROM PCD_Queue WHERE 1=1 AND ((Stat is null) or (Stat=0) )  AND PCDO_ID=@PCDO_ID ";

            idb.AddParameter("@PCDO_ID", pCDO_ID);

            SqlDataReader dr = null;

            try {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    if (dr["PCDO_ID"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_ID = Convert.ToInt64(dr["PCDO_ID"]);
                    }
                    if (dr["PCDO_PlanCode"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_PlanCode = Convert.ToString(dr["PCDO_PlanCode"]);
                    }
                    if (dr["PCDO_NCode"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_NCode = Convert.ToString(dr["PCDO_NCode"]);
                    }
                    if (dr["PCDO_Order"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_Order = Convert.ToInt32(dr["PCDO_Order"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        pCD_Queue.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(pCD_Queue);
        }
示例#7
0
        /// <summary>
        /// 获取所有的PCD_Queue对象(即:一条记录
        /// </summary>
        public List <PCD_Queue> GetAll()
        {
            List <PCD_Queue> ret = new List <PCD_Queue>();
            string           sql = "SELECT  PCDO_ID,PCDO_PlanCode,PCDO_NCode,PCDO_Order,Stat FROM PCD_Queue where 1=1 AND ((Stat is null) or (Stat=0) ) order by PCDO_ID desc ";
            SqlDataReader    dr  = null;

            try {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    PCD_Queue pCD_Queue = new PCD_Queue();
                    if (dr["PCDO_ID"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_ID = Convert.ToInt64(dr["PCDO_ID"]);
                    }
                    if (dr["PCDO_PlanCode"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_PlanCode = Convert.ToString(dr["PCDO_PlanCode"]);
                    }
                    if (dr["PCDO_NCode"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_NCode = Convert.ToString(dr["PCDO_NCode"]);
                    }
                    if (dr["PCDO_Order"] != DBNull.Value)
                    {
                        pCD_Queue.PCDO_Order = Convert.ToInt32(dr["PCDO_Order"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        pCD_Queue.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                    ret.Add(pCD_Queue);
                }
            }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);
        }
示例#8
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <returns>bool</returns>
        public bool Insert(PCD_Queue model)
        {
            bool result = false;

            try
            {
                int _result = instance.Add(model);
                if (_result > 0)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
示例#9
0
        /// <summary>
        /// 添加PCD_Queue对象(即:一条记录)
        /// </summary>
        public object AddWithReturn(PCD_Queue pCD_Queue)
        {
            string sql = "INSERT INTO PCD_Queue (PCDO_PlanCode,PCDO_NCode,PCDO_Order,Stat) VALUES (@PCDO_PlanCode,@PCDO_NCode,@PCDO_Order,@Stat);SELECT @@IDENTITY AS ReturnID;";

            if (string.IsNullOrEmpty(pCD_Queue.PCDO_PlanCode))
            {
                idb.AddParameter("@PCDO_PlanCode", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCDO_PlanCode", pCD_Queue.PCDO_PlanCode);
            }
            if (string.IsNullOrEmpty(pCD_Queue.PCDO_NCode))
            {
                idb.AddParameter("@PCDO_NCode", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCDO_NCode", pCD_Queue.PCDO_NCode);
            }
            if (pCD_Queue.PCDO_Order == 0)
            {
                idb.AddParameter("@PCDO_Order", 0);
            }
            else
            {
                idb.AddParameter("@PCDO_Order", pCD_Queue.PCDO_Order);
            }
            if (pCD_Queue.Stat == 0)
            {
                idb.AddParameter("@Stat", 0);
            }
            else
            {
                idb.AddParameter("@Stat", pCD_Queue.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
            {
                var Return = idb.ReturnValue(sql);
                Ex = Return.ToString();
            }
            catch (Exception ex)
            {
                Ex = ex.Message;
            }

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

            return(Re);
        }
示例#10
0
        /// <summary>
        /// 更新PCD_Queue对象(即:一条记录
        /// </summary>
        public int Update(PCD_Queue pCD_Queue)
        {
            StringBuilder sbParameter = new StringBuilder();
            StringBuilder sb          = new StringBuilder();

            sb.Append(@"UPDATE       PCD_Queue       SET ");
            if (pCD_Queue.PCDO_PlanCode_IsChanged)
            {
                sbParameter.Append("PCDO_PlanCode=@PCDO_PlanCode, ");
            }
            if (pCD_Queue.PCDO_NCode_IsChanged)
            {
                sbParameter.Append("PCDO_NCode=@PCDO_NCode, ");
            }
            if (pCD_Queue.PCDO_Order_IsChanged)
            {
                sbParameter.Append("PCDO_Order=@PCDO_Order, ");
            }
            if (pCD_Queue.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 PCDO_ID=@PCDO_ID; ");
            string sql = sb.ToString();

            if (pCD_Queue.PCDO_PlanCode_IsChanged)
            {
                if (string.IsNullOrEmpty(pCD_Queue.PCDO_PlanCode))
                {
                    idb.AddParameter("@PCDO_PlanCode", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCDO_PlanCode", pCD_Queue.PCDO_PlanCode);
                }
            }
            if (pCD_Queue.PCDO_NCode_IsChanged)
            {
                if (string.IsNullOrEmpty(pCD_Queue.PCDO_NCode))
                {
                    idb.AddParameter("@PCDO_NCode", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCDO_NCode", pCD_Queue.PCDO_NCode);
                }
            }
            if (pCD_Queue.PCDO_Order_IsChanged)
            {
                if (pCD_Queue.PCDO_Order == 0)
                {
                    idb.AddParameter("@PCDO_Order", 0);
                }
                else
                {
                    idb.AddParameter("@PCDO_Order", pCD_Queue.PCDO_Order);
                }
            }
            if (pCD_Queue.Stat_IsChanged)
            {
                if (pCD_Queue.Stat == 0)
                {
                    idb.AddParameter("@Stat", 0);
                }
                else
                {
                    idb.AddParameter("@Stat", pCD_Queue.Stat);
                }
            }

            idb.AddParameter("@PCDO_ID", pCD_Queue.PCDO_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);
        }
示例#11
0
        /// <summary>
        /// 获取实体数据
        /// </summary>
        /// <param name='strCondition'>条件(AND Code='11')</param>
        /// <returns>model</returns>
        public PCD_Queue GetModel(int id)
        {
            PCD_Queue model = instance.GetByKey(id);

            return(model);
        }