示例#1
0
        public List <Experiance> GetExperiance(int id)
        {
            List <Experiance> l = new List <Experiance>();
            Experiance        e = new Experiance();

            try
            {
                SqlConnection con = new SqlConnection(conString);
                SqlCommand    com = new SqlCommand("SELECT * FROM Experiance WHERE id = @id", con);
                com.Parameters.AddWithValue("id", id);
                con.Open();
                SqlDataReader dr = com.ExecuteReader();
                while (dr.Read())
                {
                    e.Id         = dr[0].ToString();
                    e.Name       = dr[1].ToString();
                    e.Size       = dr[2].ToString();
                    e.Ceo        = dr[3].ToString();
                    e.Type       = dr[4].ToString();
                    e.WorkerId   = dr[5].ToString();
                    e.Position   = dr[6].ToString();
                    e.Salary     = dr[7].ToString();
                    e.StartDate  = dr[8].ToString();
                    e.FinishDate = dr[9].ToString();
                }
                dr.Close();
                con.Close();
            } catch (Exception)
            {
            }

            l.Add(e);
            return(l);
        }
示例#2
0
        public List <Experiance> GetExperiances()
        {
            List <Experiance> list = new List <Experiance>();

            SqlConnection con = new SqlConnection(conString);
            SqlCommand    com = new SqlCommand("SELECT * FROM Experiance", con);

            con.Open();

            SqlDataReader dr = com.ExecuteReader();

            while (dr.Read())
            {
                Experiance e = new Experiance();
                e.Id         = dr[0].ToString();
                e.Name       = dr[1].ToString();
                e.Size       = dr[2].ToString();
                e.Ceo        = dr[3].ToString();
                e.Type       = dr[4].ToString();
                e.WorkerId   = dr[5].ToString();
                e.Position   = dr[6].ToString();
                e.Salary     = dr[7].ToString();
                e.StartDate  = dr[8].ToString();
                e.FinishDate = dr[9].ToString();
                list.Add(e);
            }

            dr.Close();
            con.Close();
            return(list);
        }
示例#3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Experiance experiance = db.Experiances.Find(id);

            db.Experiances.Remove(experiance);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
        public List <Experiance> SelectFromExperiance(string name, string size, string ceo, string type)
        {
            List <Experiance> l = new List <Experiance>();

            try
            {
                SqlConnection con = new SqlConnection(conString);
                SqlCommand    com = new SqlCommand("SELECT * FROM Experiance", con);
                if (type != "")
                {
                    com = new SqlCommand("SELECT * FROM Experiance WHERE type = @type", con);
                    com.Parameters.AddWithValue("type", type);
                }
                else
                if (ceo != "")
                {
                    com = new SqlCommand("SELECT * FROM Experiance WHERE ceo = @ceo", con);
                    com.Parameters.AddWithValue("ceo", ceo);
                }
                else
                if (size != "")
                {
                    com = new SqlCommand("SELECT * FROM Experiance WHERE size > @size", con);
                    com.Parameters.AddWithValue("size", size);
                }
                else
                if (name != "")
                {
                    com = new SqlCommand("SELECT * FROM Experiance WHERE name = @name", con);
                    com.Parameters.AddWithValue("name", name);
                }

                con.Open();

                SqlDataReader dr = com.ExecuteReader();
                while (dr.Read())
                {
                    Experiance e = new Experiance();
                    e.Id         = dr[0].ToString();
                    e.Name       = dr[1].ToString();
                    e.Size       = dr[2].ToString();
                    e.Ceo        = dr[3].ToString();
                    e.Type       = dr[4].ToString();
                    e.WorkerId   = dr[5].ToString();
                    e.Position   = dr[6].ToString();
                    e.Salary     = dr[7].ToString();
                    e.StartDate  = dr[8].ToString();
                    e.FinishDate = dr[9].ToString();
                    l.Add(e);
                }
                dr.Close();
                con.Close();
            }
            catch (Exception) { }
            return(l);
        }
示例#5
0
 public ActionResult Edit([Bind(Include = "ID,StartDate,StopDate,JobName,CompanyName,Where,Explanation")] Experiance experiance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(experiance).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(experiance));
 }
示例#6
0
        public ActionResult Create([Bind(Include = "ID,StartDate,StopDate,JobName,CompanyName,Where,Explanation")] Experiance experiance)
        {
            if (ModelState.IsValid)
            {
                db.Experiances.Add(experiance);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(experiance));
        }
        public static ExperianceDto ToExperianceDto(this Experiance experiance)
        {
            if (experiance == null)
            {
                return(null);
            }

            return
                (new ExperianceDto
            {
                ExperianceType = (ExperianceType)experiance.ExperianceType
            });
        }
示例#8
0
        // GET: Experiances/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Experiance experiance = db.Experiances.Find(id);

            if (experiance == null)
            {
                return(HttpNotFound());
            }
            return(View(experiance));
        }