public ActionResult Edit(int staffId)
 {
     if (staffId < 0)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     if (staffId < 0)
     {
         return HttpNotFound();
     }
         ModelState.Clear();
         DailyHours d = new DailyHours();
         d.getData(staffId);
         return View(d);
 }
        public ActionResult Add(DailyHours h)
        {
            if (h == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            if (h == null)
            {
                return HttpNotFound();
            }
            h.InsertDailyhours(h);
            ModelState.Clear();
            DailyHours d = new DailyHours();
            d.getNames();
            return View(d);

        }
        public ActionResult Edit(DailyHours d, string command)
        {
            if (d == null || string.IsNullOrEmpty(command))
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            if (d == null || string.IsNullOrEmpty(command))
            {
                return HttpNotFound();
            }
            if (command.Equals("Update"))
            {

                d.UpdateDailyHours(d);

            }
            else
            {
                d.DeleteDailyHours(d);
            }
            return RedirectToAction("Details");
        }
Exemplo n.º 4
0
        public void DeleteDailyHours(DailyHours s)
        {
            try
            {
                string          constr = ConfigurationManager.ConnectionStrings["dbCon"].ConnectionString;
                MySqlConnection con    = new MySqlConnection();
                con.ConnectionString = constr;
                con.Open();
                MySqlCommand cmd = new MySqlCommand("deleteDailyHours", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@icurrentDate", Convert.ToDateTime(s.currentDate).ToString("yyyy-MM-dd"));
                cmd.Parameters.AddWithValue("@iStaff_staffId", s.staffId);

                cmd.ExecuteNonQuery();

                con.Close();
            }
            catch
            {
                System.Diagnostics.Debug.WriteLine("fail !");
            }
        }
Exemplo n.º 5
0
        public void DeleteDailyHours(DailyHours s)
        {
            try
            {
                string constr = ConfigurationManager.ConnectionStrings["dbCon"].ConnectionString;
                MySqlConnection con = new MySqlConnection();
                con.ConnectionString = constr;
                con.Open();
                MySqlCommand cmd = new MySqlCommand("deleteDailyHours", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@icurrentDate", Convert.ToDateTime(s.currentDate).ToString("yyyy-MM-dd"));
                cmd.Parameters.AddWithValue("@iStaff_staffId", s.staffId);

                cmd.ExecuteNonQuery();

                con.Close();
            }
            catch
            {
                System.Diagnostics.Debug.WriteLine("fail !");
            }
        }
 public ActionResult Add()
 {
     DailyHours d = new DailyHours();
     d.getNames();
     return View(d);
 }