Example #1
0
        public static Table_1 CreateTable_1(string name, int ID)
        {
            Table_1 table_1 = new Table_1();

            table_1.Name = name;
            table_1.Id   = ID;
            return(table_1);
        }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Table_1 table_1 = db.Table_1.Find(id);

            db.Table_1.Remove(table_1);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
 public HttpResponseMessage Post(Table_1 table)
 {
     if (ModelState.IsValid)
     {
         var createdata = Tabledall.createtable(table);
         return(Request.CreateResponse(HttpStatusCode.Created, createdata));
     }
     return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "invalid sintaxxxx"));
 }
Example #4
0
 /// <summary>
 /// 删除指定数据
 /// </summary>
 /// <param name="UserID">要删除的对象  (通过唯一键)</param>
 /// <returns></returns>
 public int Delete(Table_1 _table_1)
 {
     return(db.ExecuteNonQuery(deleteByKeyText, CommandType.Text,
                               new SqlParameter[] {
         new SqlParameter("@UserID", SqlDbType.VarChar, 50)
         {
             Value = _table_1.UserID
         }
     }));
 }
Example #5
0
 public ActionResult Edit([Bind(Include = "id,Name,Lastname,Email")] Table_1 table_1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table_1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table_1));
 }
Example #6
0
 public ActionResult Edit([Bind(Include = "MaSach,TenSach,Giá,TG,SL")] Table_1 table_1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table_1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table_1));
 }
Example #7
0
 public ActionResult Edit([Bind(Include = "substore,subsid,price")] Table_1 table_1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table_1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table_1));
 }
Example #8
0
        /// <summary>
        /// 新增一筆紀錄
        /// </summary>
        /// <param name="Para"></param>
        /// <param name="MemId"></param>
        public void Create(CreateTableIn Para, int MemId)
        {
            var CreateInfo = _tbrep.GetAll().OrderByDescending(d => d.Id).Take(1).FirstOrDefault();
            var data       = new Table_1()
            {
                //實作內容
            };

            _tbrep.Create(data);
            _tbrep.Save();
        }
Example #9
0
        public ActionResult Create([Bind(Include = "substore,subsid,price")] Table_1 table_1)
        {
            if (ModelState.IsValid)
            {
                db.Table_1.Add(table_1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(table_1));
        }
Example #10
0
        public ActionResult Create([Bind(Include = "MaSach,TenSach,Giá,TG,SL")] Table_1 table_1)
        {
            if (ModelState.IsValid)
            {
                db.Table_1.Add(table_1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(table_1));
        }
Example #11
0
        public ActionResult Create([Bind(Include = "Carnumber,Cars,Models,Price")] Table_1 table_1)
        {
            if (ModelState.IsValid)
            {
                db.Table_1.Add(table_1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(table_1));
        }
Example #12
0
        public ActionResult Create([Bind(Include = "id,Name,Lastname,Email")] Table_1 table_1)
        {
            if (ModelState.IsValid)
            {
                db.Table_1.Add(table_1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(table_1));
        }
        // GET: Table_1/Delete/5
        public ActionResult Delete(int id)
        {
            Table_1 b = db.Table_1s.Find(id);

            if (b != null)
            {
                db.Table_1s.Remove(b);
                db.SaveChanges();
            }
            //  return RedirectToAction("/Syrie/Index");
            return(View());
        }
Example #14
0
        static Table_1 ModelToEntity(DefaultViewModel d)
        {
            Table_1 t = null;

            if (d != null)
            {
                t             = new Table_1();
                t.id          = d.Id;
                t.description = d.Description;
            }
            return(t);
        }
Example #15
0
        public void AddRecordTest()
        {
            var newRecord = new Table_1()
            {
                city_name   = "LOL",
                city_id     = "122",
                temperature = 20.5,
            };

            context.Table_1.Add(newRecord);
            context.SaveChanges();
        }
        public ActionResult Index()
        {
            var data = _uowTable.GetAll.ToList();
            var user = new Table_1 {
                Name = "User" + data.Count
            };

            user = _uowTable.Add(user);
            var result = _unitOfWork.Commit;

            return(View());
        }
Example #17
0
        // == CRUD operations section ==

        public void AddCommandHandler(object sender, ExecutedRoutedEventArgs e)
        {
            var newRecord = new Table_1()
            {
                city_name   = city_nameTextBox.Text,
                city_id     = city_idTextBox.Text,
                temperature = double.Parse(temperatureTextBox.Text),
            };

            context.Table_1.Add(newRecord);
            context.SaveChanges();
            tabViewSource.View.Refresh();
        }
Example #18
0
 public ActionResult Edit([Bind(Include = "ID,Image,Hide,Type,Size,Colour,Price,Stock,Description,ProductID,Additional")] Table_1 table_1)
 {
     if (table_1.Image == null)
     {
         table_1.Image = "https://www.hiderugs.co.uk/wp-content/uploads/2017/02/logo.jpg";
     }
     if (ModelState.IsValid)
     {
         db.Entry(table_1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table_1));
 }
Example #19
0
        // GET: Table_1/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Table_1 table_1 = db.Table_1.Find(id);

            if (table_1 == null)
            {
                return(HttpNotFound());
            }
            return(View(table_1));
        }
        //[AllowAnonymous]
        // GET: Table_1/Details/5
        public ViewResult Details(int?id)
        {
            if (id == null)
            {
                return(View("Error"));
            }
            Table_1 table_1 = db.Table_1.FirstOrDefault(a => a.Carid == id);

            if (table_1 == null)
            {
                return(View("Error"));
            }
            return(View(table_1));
        }
Example #21
0
        // GET: submit
        public ActionResult data(string rname, int skill, DateTime sdate, DateTime edate)
        {
            elhanEntities1 e = new elhanEntities1();
            Table_1        t = new Table_1();

            t.name      = rname;
            t.skill     = skill;
            t.startdate = sdate;
            t.enddate   = edate;
            e.Table_1.Add(t);
            e.SaveChanges();

            return(View());
        }
Example #22
0
        // == Downloading data from the OpenWeatherAPI section ==

        private async void GetApiData()
        {
            Random random     = new Random();
            string apiKey     = "747fe0e760b5276cc648effd30d3a2a8";
            string apiBaseUrl = "https://api.openweathermap.org/data/2.5/weather";

            await Task.Run(() =>
            {
                using (var client = new WebClient())
                {
                    while (true)
                    {
                        double lat = random.Next(35, 71);
                        double lon = random.Next(-9, 68);

                        string apiCall = apiBaseUrl + "?lat=" + lat + "&lon=" + lon + "&apikey=" + apiKey +
                                         "&mode=json&units=metric";

                        string jsonString = client.DownloadString(apiCall);
                        var jsonObject    = JsonConvert.DeserializeObject <JObject>(jsonString);
                        string j_name     = jsonObject["name"].ToString();
                        string j_id       = jsonObject["id"].ToString();
                        string j_temp     = jsonObject["main"]["temp"].ToString();

                        if (j_name == "")
                        {
                            j_name = "Ocean or See";
                        }

                        var newRecord = new Table_1()
                        {
                            city_name   = j_name,
                            city_id     = j_id,
                            temperature = double.Parse(j_temp),
                        };

                        Dispatcher.Invoke(() =>
                        {
                            context.Table_1.Add(newRecord);
                            context.SaveChanges();
                            tabViewSource.View.Refresh();
                        });

                        Thread.Sleep(5000);
                    }
                }
            });
        }
        public ViewResult DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(View("Error"));
            }

            Table_1 table_1 = db.Table_1.FirstOrDefault(a => a.Carid == id);

            if (table_1 == null)
            {
                return(View("Error"));
            }

            db.Delete(table_1);

            return(View("Index"));
        }
Example #24
0
 public ActionResult Delete(int ID, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         using (dbModel Dbmodel = new dbModel())
         {
             Table_1 table_1 = Dbmodel.Table_1.Where(x => x.id == ID).FirstOrDefault();
             Dbmodel.Table_1.Remove(table_1);
             Dbmodel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #25
0
        public ActionResult Edit(int id, Table_1 table_1)
        {
            try
            {
                using (dbModel Dbmodel = new dbModel())
                {
                    Dbmodel.Entry(table_1).State = EntityState.Modified;
                    Dbmodel.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #26
0
        public ActionResult Create(Table_1 table_1)
        {
            try
            {
                using (dbModel DbModel = new dbModel())
                {
                    DbModel.Table_1.Add(table_1);
                    DbModel.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #27
0
        static void Main(string[] args)
        {
            var     bll = new Table_1BLL();
            Table_1 t   = new Table_1();

            t.Iden   = 1;
            t.S1     = 2;
            t.S2     = 4;
            t.UserID = "wq";
            t.ID     = 123;
            t.ID     = bll.Add(t);
            Console.WriteLine(t.ID);
            Console.WriteLine(t.SSum);
            t.ID = 23;
            var s = bll.Update(t);

            Console.WriteLine("更新成功:" + s);
            Console.ReadKey();
        }
Example #28
0
        /// <summary>
        /// 将表转换为对象集合
        /// </summary>
        /// <param name="dt">要转换的表</param>
        /// <returns></returns>
        public List <Table_1> DataTableToList(DataTable dt)
        {
            List <Table_1>       table_1s = new List <Table_1>();
            Table_1              _table_1 = null;
            object               _temp    = null;
            DataColumnCollection dcs      = dt.Columns;

            foreach (DataRow item in dt.Rows)
            {
                _table_1 = new Table_1();
                if (dcs.Contains("id"))
                {
                    _table_1.ID = Convert.ToInt64(item["ID"]);
                }
                if (dcs.Contains("userid"))
                {
                    _table_1.UserID = item["UserID"].ToString();
                }
                if (dcs.Contains("iden"))
                {
                    _table_1.Iden = Convert.ToInt32(item["Iden"]);
                }
                if (dcs.Contains("s1"))
                {
                    _table_1.S1 = Convert.ToDecimal(item["s1"]);
                }
                if (dcs.Contains("s2"))
                {
                    _table_1.S2 = Convert.ToDecimal(item["s2"]);
                }
                if (dcs.Contains("ssum"))
                {
                    _temp = item["SSum"];
                    if (!(_temp is DBNull))
                    {
                        _table_1.SSum = Convert.ToDecimal(_temp);
                    }
                }
                table_1s.Add(_table_1);
            }
            return(table_1s);
        }
Example #29
0
        public HttpResponseMessage Put(int id, Table_1 table)
        {
            // kayıtlı id yoksa


            if (Tabledall.kayitvarmi(id) == false)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "kayıt bulunamadı ...."));
            }
            // girilen datalar uyuşmuyorsa
            else if (ModelState.IsValid == false)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "uyumlu değiş"));
            }
            //ok
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, Tabledall.updatetable(id, table)));
            }
        }
Example #30
0
        public ActionResult UpdateItem(string itemIds)
        {
            int        count      = 1;
            List <int> itemIdList = new List <int>();

            itemIdList = itemIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
            foreach (var itemId in itemIdList)
            {
                try
                {
                    Table_1 item = db.Table_1.Where(x => x.id == itemId).FirstOrDefault();
                    item.rowNo = count;
                    db.Table_1.AddOrUpdate(item);
                    db.SaveChanges();
                }
                catch (Exception)
                {
                    continue;
                }
                count++;
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
 public void AddToTable_1(Table_1 table_1)
 {
     base.AddObject("Table_1", table_1);
 }
 public static Table_1 CreateTable_1(string name, int ID)
 {
     Table_1 table_1 = new Table_1();
     table_1.Name = name;
     table_1.Id = ID;
     return table_1;
 }