Beispiel #1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="car"></param>
        /// <returns></returns>
        public bool Update(PartUpdateModel model)
        {
            DAO.Parts c = db.Parts.Where(m => m.ID == model.ID).FirstOrDefault();

            c.PartName        = model.PartName;
            c.CategoryID      = model.CategoryID;
            c.PartBrand       = model.PartBrand;
            c.PartModel       = model.PartModel;
            c.PartSuppyNo     = model.PartSuppyNo;
            c.Price           = model.Price;
            c.Orderby         = model.Orderby;
            c.State           = model.State;
            c.ToCars          = model.ToCars;
            c.PartTitle       = model.PartTitle;
            c.PartSubtitle    = model.PartSubtitle;
            c.Describe        = model.Describe;
            c.ShowDate        = DateTime.Now;
            db.Entry(c).State = System.Data.EntityState.Modified;
            int result = db.SaveChanges();

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条记录
        /// </summary>
        /// <param name="car">汽车实体</param>
        /// <returns></returns>
        public DAO.Parts Add(DAO.Parts model)
        {
            DAO.Parts m = db.Parts.Add(model);
            int       i = db.SaveChanges();

            if (i > 0)
            {
                return(m);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
 /// <summary>
 /// 获取Model
 /// </summary>
 /// <param name="partId"></param>
 /// <returns></returns>
 public DAO.Parts GetPartModel(int partId)
 {
     DAO.Parts part = db.Parts.Where(m => m.ID == partId).FirstOrDefault();
     return(part);
 }
Beispiel #4
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="car"></param>
        /// <returns></returns>
        public bool Update(PartUpdateModel model)
        {
            DAO.Parts c = db.Parts.Where(m => m.ID == model.ID).FirstOrDefault();

            c.PartName       = model.PartName;
            c.CategoryID     = model.CategoryID;
            c.PartBrand      = model.PartBrand;
            c.HotProductId   = model.HotTable;
            c.PartModel      = model.PartModel;
            c.PartSuppyNo    = model.PartSuppyNo;
            c.Price          = model.Price;
            c.Orderby        = model.Orderby;
            c.mDescribe      = model.mDescribe;
            c.ProType        = model.ProType;
            c.State          = model.State;
            c.supply         = model.supply;
            c.storeName      = model.storeName;
            c.material       = model.material;
            c.specifications = model.specifications;
            c.useSite        = model.useSite;
            c.ParsColour     = model.ParsColour;
            c.herf           = model.herf;
            if (model.ToCars == ",")
            {
                c.ToCars = "*";
            }
            else
            {
                c.ToCars = model.ToCars;
            }

            c.PartTitle    = model.PartTitle;
            c.PartSubtitle = model.PartSubtitle;
            c.Describe     = model.Describe;
            c.ShowDate     = DateTime.Now;



            string sql = "update [Parts] set PartName='" + model.PartName + "', CategoryID=" + model.CategoryID + ", PartTitle='" + model.PartTitle + "', PartSubtitle='" + model.PartSubtitle + "', PartBrand='" + model.PartBrand + "', PartModel='" + model.PartModel + "', PartSuppyNo='" + model.PartSuppyNo + "'," +
                         "Price=" + model.Price + ", ToCars='" + model.ToCars + "', Describe='" + model.Describe + "',  Orderby='" + model.Orderby + "',State='" + model.State + "',mDescribe='" + model.mDescribe + "',ProType='" + model.ProType + "'," +
                         "HotProductId='" + model.HotTable + "',supply='" + model.supply + "',storeName='" + model.storeName + "',material='" + model.material + "',specifications='" + model.specifications + "',useSite='" + model.useSite + "',ParsColour='" + model.ParsColour + "',herf='" + model.herf + "',ShowDate='" + DateTime.Now + "' where ID={0}";
            int i = db.Database.ExecuteSqlCommand(string.Format(sql, model.ID));

            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
            db.Entry(c).State = System.Data.EntityState.Modified;
            try
            {
                int result = db.SaveChanges();
                if (result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }