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

            if (_rseult > 0)
            {
                result = true;
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 获取实体数据
        /// </summary>
        /// <param name='strCondition'>条件(AND Code='11')</param>
        /// <returns>model</returns>
        public WH_Price GetModel(string strCondition)
        {
            List <WH_Price> list  = instance.GetListByWhere(strCondition);
            WH_Price        model = new WH_Price();

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

            if (list.Count > 0)
            {
                WH_Price model = list[0];
                model.Stat = 1;
                int _rseult = instance.Update(model);
                if (_rseult > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
示例#5
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name='model'>实体</param>
        /// <returns>bool</returns>
        public bool Insert(WH_Price model)
        {
            bool result = false;

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

            return(result);
        }
示例#6
0
        /// <summary>
        /// 获取指定的WH_Price对象集合
        /// </summary>
        public List <WH_Price> GetListByWhere(string strCondition, string spread)
        {
            List <WH_Price> ret = new List <WH_Price>();
            string          sql = "SELECT*FROM WH_Price JOIN WH_Material ON WH_Price.WP_MCode=WH_Material.MD_MCode JOIN WH_Storage  ON WH_Material.MD_MCode=WH_Storage.Storage_MaterielCode WHERE 1=1 AND ((WH_Material.Stat is null) or (WH_Material.Stat=0) ) ";

            if (!string.IsNullOrEmpty(strCondition))
            {
                strCondition.Replace('\'', '"'); //防sql注入
                sql += strCondition;
            }
            sql += " ORDER BY WP_ID DESC ";
            SqlDataReader dr = null;

            try
            {
                dr = (SqlDataReader)idb.ReturnReader(sql);
                while (dr.Read())
                {
                    WH_Price wH_Price = new WH_Price();
                    if (dr["WP_ID"] != DBNull.Value)
                    {
                        wH_Price.WP_ID = Convert.ToInt64(dr["WP_ID"]);
                    }
                    if (dr["WP_CCode"] != DBNull.Value)
                    {
                        wH_Price.WP_CCode = Convert.ToString(dr["WP_CCode"]);
                    }
                    if (dr["WP_CName"] != DBNull.Value)
                    {
                        wH_Price.WP_CName = Convert.ToString(dr["WP_CName"]);
                    }
                    if (dr["WP_MCode"] != DBNull.Value)
                    {
                        wH_Price.WP_MCode = Convert.ToString(dr["WP_MCode"]);
                    }
                    if (dr["WP_Price"] != DBNull.Value)
                    {
                        wH_Price.WP_Price = Convert.ToDecimal(dr["WP_Price"]);
                    }
                    if (dr["WP_Num"] != DBNull.Value)
                    {
                        wH_Price.WP_Num = Convert.ToDecimal(dr["WP_Num"]);
                    }
                    if (dr["WP_ONum"] != DBNull.Value)
                    {
                        wH_Price.WP_ONum = Convert.ToDecimal(dr["WP_ONum"]);
                    }
                    if (dr["WP_PNum"] != DBNull.Value)
                    {
                        wH_Price.WP_PNum = Convert.ToDecimal(dr["WP_PNum"]);
                    }
                    if (dr["WP_Udef1"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef1 = Convert.ToString(dr["WP_Udef1"]);
                    }
                    if (dr["WP_Udef2"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef2 = Convert.ToString(dr["WP_Udef2"]);
                    }
                    if (dr["WP_Udef3"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef3 = Convert.ToString(dr["WP_Udef3"]);
                    }
                    if (dr["WP_Udef4"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef4 = Convert.ToString(dr["WP_Udef4"]);
                    }
                    if (dr["WP_Udef5"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef5 = Convert.ToString(dr["WP_Udef5"]);
                    }
                    if (dr["WP_Udef6"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef6 = Convert.ToString(dr["WP_Udef6"]);
                    }
                    if (dr["WP_Udef7"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef7 = Convert.ToString(dr["WP_Udef7"]);
                    }
                    if (dr["WP_Udef8"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef8 = Convert.ToString(dr["WP_Udef8"]);
                    }
                    if (dr["WP_Udef9"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef9 = Convert.ToString(dr["WP_Udef9"]);
                    }
                    if (dr["WP_Udef10"] != DBNull.Value)
                    {
                        wH_Price.WP_Udef10 = Convert.ToString(dr["WP_Udef10"]);
                    }
                    if (dr["Stat"] != DBNull.Value)
                    {
                        wH_Price.Stat = Convert.ToInt32(dr["Stat"]);
                    }
                    //扩展属性
                    //if (dr["Storage_Count"] != DBNull.Value) wH_Price.Storage_Count = Convert.ToInt32(dr["Storage_Count"]);
                    if (dr["Storage_TNum"] != DBNull.Value)
                    {
                        wH_Price.Storage_TNum = Convert.ToInt32(dr["Storage_TNum"]);
                    }
                    if (dr["Storage_LNum"] != DBNull.Value)
                    {
                        wH_Price.Storage_LNum = Convert.ToInt32(dr["Storage_LNum"]);
                    }
                    if (dr["Storage_Dvalue"] != DBNull.Value)
                    {
                        wH_Price.Storage_Dvalue = Convert.ToDecimal(dr["Storage_Dvalue"]);
                    }
                    ret.Add(wH_Price);
                }
            }
            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);
        }
示例#7
0
        /// <summary>
        /// 获取实体数据
        /// </summary>
        /// <param name='strCondition'>条件(AND Code='11')</param>
        /// <returns>model</returns>
        public WH_Price GetModel(int id)
        {
            WH_Price model = instance.GetByKey(id);

            return(model);
        }