Exemple #1
0
        internal string sysConfigUpdate(sysConfig sys)
        {
            string sql = @"UPDATE sysConfig
                           SET
                           stockUpdate = @stockUpdate, 
                           otcUpdate = @otcUpdate, 
                           nowDate = @nowDate,  
                           avgStartDate = @avgStartDate,  
                           avgEndDate = @avgEndDate 
                           WHERE id = @id;";

            using (var db = new WebStockEntities())
            {
                if (sys != null)
                {
                    int res = db.Database.ExecuteSqlCommand(sql,
                                                            new SqlParameter("@stockUpdate", sys.stockUpdate),
                                                            new SqlParameter("@otcUpdate", sys.otcUpdate),
                                                            new SqlParameter("@nowDate", sys.nowDate),
                                                            new SqlParameter("@avgStartDate", sys.avgStartDate),
                                                            new SqlParameter("@avgEndDate", sys.avgEndDate),
                                                            new SqlParameter("@id", sys.id)
                                                            );
                    db.SaveChanges();
                    return("upDate success !");
                }
                else
                {
                    return("upDate error !");
                }
            }
        }
Exemple #2
0
 internal bool EditSysConfig(sysConfig sys)
 {
     using (var db = new WebStockEntities())
     {
         sysConfig d = db.sysConfig.Where(x => x.id == 1).FirstOrDefault();
         Mapper.Initialize(cfg => cfg.CreateMap <sysConfig, sysConfig>()
                           .ForMember(x => x.id, opt => opt.Ignore())
                           );
         Mapper.Map(sys, d);
         int r = db.SaveChanges();
         return(r >= 0 ? true : false);
     }
 }