Exemplo n.º 1
0
 public ActionResult EditEmpDetails(int id, Models.EmpModel obj)
 {
     try
     {
         // TODO: Add update logic here
         EmpRepository EmpRepo = new EmpRepository();
         EmpRepo.UpdateEmployee(obj);
         return(RedirectToAction("GetAllEmpDetails"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 2
0
        private static string conString = "server = localhost; port=3306;database=3dstask;user=root;password=santu672;";//ConfigurationManager.AppSettings. ConnectionStrings["conString"].ToString();

        public static void AddEmployee(Models.EmpModel model)
        {
            using (MySqlConnection con = new MySqlConnection(conString))
            {
                con.Open();
                using (MySqlCommand cmd = new MySqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "Insert into employee(Name,City,Salary) Values(" + model.Name + "," + model.City + "," + model.Salary + ")";
                    cmd.ExecuteNonQuery();
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult AddEmployee(Models.EmpModel Emp)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    EmpRepository EmpRepo = new EmpRepository();

                    if (EmpRepo.AddEmployee(Emp))
                    {
                        ViewBag.Message = "Employee details added successfully";
                    }
                }

                return(View());
            }
            catch
            {
                return(View());
            }
        }