public ActionResult Worktype_Edit(juggle.Models.tbl_worktype work_type)
 {
     try
     {
         using (jugglecontext dbcon = new jugglecontext())
         {
             tbl_worktype worktype = new tbl_worktype();
             worktype.name  = work_type.name.Trim();
             worktype.color = work_type.color;
             var time = Request.Form["multiple"];
             worktype.time               = time;
             worktype.work_id            = work_type.work_id;
             worktype.updated_date       = DateTime.Now;
             worktype.user_id            = work_type.user_id;
             worktype.created_date       = work_type.created_date;
             dbcon.Entry(worktype).State = System.Data.Entity.EntityState.Modified;
             dbcon.SaveChanges();
             return(RedirectToAction("Work_type", "Work_type"));
         }
     }
     catch
     {
         return(View());
     }
 }
Example #2
0
        public ActionResult Employeeavailibility_Edit(tbl_employee_availability employee)
        {
            if (Session["User_Id"] != null)
            {
                using (jugglecontext dbcon = new jugglecontext())
                {
                    try
                    {
                        tbl_employee_availability empl = new tbl_employee_availability();
                        empl.emp_id             = employee.emp_id;
                        empl.start_date         = Convert.ToDateTime(employee.start_date);
                        empl.end_date           = Convert.ToDateTime(employee.end_date);
                        empl.userid             = Convert.ToInt32(Session["User_Id"]);
                        empl.time_range_start   = employee.time_range_start;
                        empl.time_range_end     = employee.time_range_end;
                        empl.created_date       = employee.created_date;
                        empl.updated_date       = DateTime.Now;
                        empl.empavailability_id = Convert.ToInt32(employee.empavailability_id);
                        dbcon.Entry(empl).State = System.Data.Entity.EntityState.Modified;
                        dbcon.SaveChanges();

                        // when employee delete at that time his/her assigned appointment will be upassign
                        SqlConnection connection = new SqlConnection(dbcon.connectionString());
                        var           command    = new SqlCommand("[updateempavailibility]", connection);
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@startdate", Convert.ToDateTime(employee.start_date));
                        command.Parameters.AddWithValue("@enddate", Convert.ToDateTime(employee.end_date));
                        command.Parameters.AddWithValue("@StartTime", employee.time_range_start);
                        command.Parameters.AddWithValue("@endTime", employee.time_range_end);
                        command.Parameters.AddWithValue("@emp_id", Convert.ToInt32(employee.emp_id));
                        command.Parameters.AddWithValue("@type", "edit");
                        connection.Open();
                        SqlDataReader rdr = command.ExecuteReader();



                        return(RedirectToAction("EmployeeAvailability", "EmployeeAvailability"));
                    }

                    catch (DbEntityValidationException ex)
                    {
                        foreach (var entityValidationErrors in ex.EntityValidationErrors)
                        {
                            foreach (var validationError in entityValidationErrors.ValidationErrors)
                            {
                                Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                            }
                        }
                    }
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
            return(View());
        }
Example #3
0
        public ActionResult changePassword(changePassword changepass)
        {
            if (Session["User_Id"] != null)
            {
                using (jugglecontext dbcon = new jugglecontext())
                {
                    var      old_pass = changepass.oldPassword.ToString().Trim();
                    var      new_pass = dbcon.Encrypt(changepass.NewPassword.ToString());
                    tbl_user user     = null;

                    var    user_id = Convert.ToInt32(Session["User_Id"].ToString());
                    string password_fromdb;
                    var    getuser_pass = dbcon.tbl_user.SingleOrDefault(user_id_db => user_id_db.user_id == user_id);
                    user = dbcon.tbl_user.Where(s => s.user_id == user_id).FirstOrDefault <tbl_user>();
                    if (getuser_pass != null)
                    {
                        password_fromdb = dbcon.Decrypt(getuser_pass.password.ToString());
                        if (password_fromdb == old_pass)
                        {
                            user.password = Convert.ToString(new_pass);

                            dbcon.tbl_user.Attach(user);
                            dbcon.Entry(user).State = System.Data.Entity.EntityState.Modified;
                            dbcon.SaveChanges();
                            ViewBag.message = "Your password has been changed.";
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(old_pass))
                            {
                                ModelState.AddModelError("oldPassword", "Please enter old password.");
                            }
                            else
                            {
                                ModelState.AddModelError("", "Invalid old password!");
                            }
                        }
                    }
                    else
                    {
                        ViewBag.InvalidUser = "******";
                    }
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }

            return(View());
        }
Example #4
0
        public ActionResult Edit_Supervisorprofile(tbl_user tbluser)
        {
            if (Session["User_Id"] != null)
            {
                using (jugglecontext dbcon = new jugglecontext())
                {
                    tbl_user users  = new tbl_user();
                    var      userId = Convert.ToInt32(Session["User_Id"]);
                    users.supervisor_id     = tbluser.supervisor_id;
                    users.user_id           = tbluser.user_id;
                    users.firstName         = tbluser.firstName;
                    users.lastName          = tbluser.lastName;
                    users.address           = tbluser.address;
                    users.phoneno           = tbluser.phoneno;
                    users.email             = tbluser.email;
                    users.status            = tbluser.status;
                    users.username          = tbluser.username;
                    users.password          = tbluser.password;
                    users.created_date      = tbluser.created_date;
                    users.updated_date      = DateTime.Now;
                    users.timezoneid        = "Central Standard Time";
                    Session["firstname"]    = tbluser.firstName;
                    Session["profile_pict"] = tbluser.profile_pict;
                    if (Request.Files.Count > 0)
                    {
                        var file = Request.Files[0];
                        if (file != null && file.ContentLength > 0)
                        {
                            var fileName = Path.GetFileName(file.FileName);

                            users.profile_pict = fileName;

                            var path = Path.Combine(Server.MapPath("~/Profile_Picture/"), fileName);
                            file.SaveAs(path);
                        }
                        else
                        {
                            users.profile_pict = tbluser.profile_pict;
                        }
                    }
                    users.role_id            = 2;
                    dbcon.Entry(users).State = System.Data.Entity.EntityState.Modified;
                    dbcon.SaveChanges();
                    return(RedirectToAction("Index", "SupervisorProfile"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
        public ActionResult Employee_Edit(tbl_employee_info employee)
        {
            if (Session["User_Id"] != null)
            {
                using (jugglecontext dbcon = new jugglecontext())
                {
                    try
                    {
                        string            multipleattribute = Request.Form["attribute_id_multiple"].ToString();
                        string            multipleservice   = Request.Form["emp_qualifiedservicetypes_multiple"].ToString();
                        tbl_employee_info empl = new tbl_employee_info();
                        empl.emp_id                    = employee.emp_id;
                        empl.emp_firstname             = employee.emp_firstname;
                        empl.emp_lastname              = employee.emp_lastname;
                        empl.emp_qualifiedservicetypes = multipleservice;
                        empl.user_id                   = employee.user_id;
                        empl.created_date              = employee.created_date;
                        empl.emp_code                  = autogenerateid();
                        empl.updated_date              = DateTime.Now;
                        empl.emp_contactinfo           = employee.emp_contactinfo;
                        empl.attribute_id              = multipleattribute;
                        empl.emp_transportion          = employee.emp_transportion;
                        empl.emp_googlecalendarID      = employee.emp_googlecalendarID;
                        empl.emp_note                  = employee.emp_note;
                        empl.emp_password              = dbcon.Encrypt(employee.emp_password);

                        dbcon.Entry(empl).State = System.Data.Entity.EntityState.Modified;
                        dbcon.SaveChanges();
                        return(RedirectToAction("Employee", "Employee"));
                    }
                    catch (DbEntityValidationException ex)
                    {
                        foreach (var entityValidationErrors in ex.EntityValidationErrors)
                        {
                            foreach (var validationError in entityValidationErrors.ValidationErrors)
                            {
                                Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                            }
                        }
                    }
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
            return(View());
        }
 public ActionResult Edit_Workers(juggle.Models.tbl_user tbluser)
 {
     if (Session["User_Id"] != null)
     {
         using (jugglecontext dbcon = new jugglecontext())
         {
             var getstatusId = 0;
             try
             {
                 getstatusId = Convert.ToInt32(Request.Form["status_hidden"]);
             }
             catch { }
             tbl_user users  = new tbl_user();
             var      userId = Convert.ToInt32(Session["User_Id"]);
             users.user_id       = tbluser.user_id;
             users.firstName     = tbluser.firstName;
             users.lastName      = tbluser.lastName;
             users.address       = tbluser.address;
             users.phoneno       = tbluser.phoneno;
             users.email         = tbluser.email;
             users.supervisor_id = userId;
             users.username      = tbluser.username;
             users.password      = tbluser.password;
             if (getstatusId == 0)
             {
                 users.status = tbluser.status;
             }
             else
             {
                 users.status = Convert.ToInt32(getstatusId);
             }
             users.created_date       = tbluser.created_date;
             users.updated_date       = DateTime.Now;
             users.role_id            = 3;
             dbcon.Entry(users).State = System.Data.Entity.EntityState.Modified;
             dbcon.SaveChanges();
             return(RedirectToAction("ManageWorkers", "Workers"));
         }
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
 public ActionResult Worktype_Category_Edit(juggle.Models.tbl_worktype_category work_type_category)
 {
     try
     {
         using (jugglecontext dbcon = new jugglecontext())
         {
             tbl_worktype_category worktype = new tbl_worktype_category();
             worktype.worktypecategory_name = work_type_category.worktypecategory_name.Trim();
             worktype.worktypecat_id        = work_type_category.worktypecat_id;
             worktype.updated_date          = DateTime.Now;
             worktype.created_date          = work_type_category.created_date;
             dbcon.Entry(worktype).State    = System.Data.Entity.EntityState.Modified;
             dbcon.SaveChanges();
             return(RedirectToAction("Worktype_category", "Work_Type_Category"));
         }
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
Example #8
0
 public ActionResult attribute_Edit(juggle.Models.tbl_attribute_data work_type_category)
 {
     try
     {
         using (jugglecontext dbcon = new jugglecontext())
         {
             var userId = Convert.ToInt32(Session["User_Id"]);
             tbl_attribute_data attribute = new tbl_attribute_data();
             attribute.attribute_name     = work_type_category.attribute_name.Trim();
             attribute.attribute_id       = work_type_category.attribute_id;
             attribute.updated_date       = DateTime.Now;
             attribute.created_date       = work_type_category.created_date;
             attribute.user_id            = userId;
             dbcon.Entry(attribute).State = System.Data.Entity.EntityState.Modified;
             dbcon.SaveChanges();
             return(RedirectToAction("attribute", "Attribute"));
         }
     }
     catch
     {
         return(View());
     }
 }
Example #9
0
        public ActionResult Client_Edit(tbl_client clientmodel)
        {
            if (Session["User_Id"] != null)
            {
                using (jugglecontext dbcon = new jugglecontext())
                {
                    string multipleattribute = Request.Form["attribute_id_multiple"].ToString();
                    var    x_lat             = 0.0;
                    var    y_long            = 0.0;
                    var    getScheduleId     = 0;
                    try
                    {
                        x_lat = Convert.ToDouble(Request.Form["x_lat"]);
                    }
                    catch
                    {
                        x_lat = 0.0;
                    }
                    try
                    {
                        y_long = Convert.ToDouble(Request.Form["y_long"]);
                    }
                    catch
                    {
                        y_long = 0.0;
                    }
                    try
                    {
                        getScheduleId = Convert.ToInt32(Request.Form["schedule_hidden"]);
                    }
                    catch { }

                    tbl_client client_info = new tbl_client();
                    client_info.client_id            = clientmodel.client_id;
                    client_info.client_firstname     = clientmodel.client_firstname;
                    client_info.client_lastname      = clientmodel.client_lastname;
                    client_info.client_companyname   = clientmodel.client_companyname;
                    client_info.client_secondaryname = clientmodel.client_secondaryname;
                    client_info.client_email         = clientmodel.client_email;
                    client_info.client_contact_info  = clientmodel.client_contact_info;
                    client_info.client_address       = clientmodel.client_address;
                    if (!string.IsNullOrEmpty(clientmodel.client_note))
                    {
                        client_info.client_note = clientmodel.client_note;
                    }
                    else
                    {
                        client_info.client_note = "N/A";
                    }

                    client_info.user_id      = clientmodel.user_id;
                    client_info.updated_date = DateTime.Now;
                    client_info.created_date = clientmodel.created_date;
                    client_info.attribute_id = multipleattribute;
                    client_info.client_code  = clientmodel.client_code;

                    if (x_lat == clientmodel.x_lat)
                    {
                        client_info.x_lat = clientmodel.x_lat;
                    }
                    else
                    {
                        client_info.x_lat = x_lat;
                    }
                    if (y_long == clientmodel.y_long)
                    {
                        client_info.y_long = clientmodel.y_long;
                    }
                    else
                    {
                        client_info.y_long = y_long;
                    }
                    dbcon.Entry(client_info).State = System.Data.Entity.EntityState.Modified;
                    dbcon.SaveChanges();
                    return(RedirectToAction("Client", "Client"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
        public ActionResult appointment_edit(juggle.Models.tbl_appointment appointment)
        {
            if (Session["User_Id"] == null)
            {
                return(RedirectToAction("Appointment", "Appointment"));
            }
            if (Session["User_Id"] != null)
            {
                try
                {
                    using (jugglecontext dbcon = new jugglecontext())
                    {
                        tbl_appointment editappointment   = new tbl_appointment();
                        string          multipleattribute = Request.Form["attribute_iddata"].ToString();
                        editappointment.appointment_id = appointment.appointment_id;
                        editappointment.description    = appointment.description;
                        editappointment.recurring      = appointment.recurring;
                        editappointment.start_date     = appointment.start_date;
                        editappointment.end_date       = appointment.end_date;
                        editappointment.time           = appointment.time;
                        string multiplevalue = Request.Form["multiple"];

                        if (appointment.recurring)
                        {
                            //appointment.end_date = null;
                        }

                        if (!string.IsNullOrEmpty(multiplevalue))
                        {
                            editappointment.day = multiplevalue;
                        }
                        else
                        {
                            multiplevalue = "0"; editappointment.day = "0";
                        }

                        editappointment.updated_date = DateTime.Now;
                        if (!string.IsNullOrEmpty(appointment.notes))
                        {
                            editappointment.notes = appointment.notes;
                        }
                        else
                        {
                            editappointment.notes = "N/A";
                        }
                        //   editappointment.notes = appointment.notes;
                        editappointment.time_range_start = appointment.time_range_start;
                        editappointment.time_range_end   = appointment.time_range_end;

                        // add two extra field that store the calendar start time and end time
                        // it is use for the event of google calendar only
                        // start

                        string   startdate1    = appointment.start_date.ToString();
                        DateTime strstartdate1 = Convert.ToDateTime(startdate1);

                        string   enddate1    = appointment.end_date.ToString();
                        DateTime strenddate1 = Convert.ToDateTime(enddate1);

                        DateTime cal_startdate = Convert.ToDateTime(strstartdate1.ToString("yyyy/MM/dd") + " " + appointment.time_range_start);
                        DateTime cal_enddate   = Convert.ToDateTime(strenddate1.ToString("yyyy/MM/dd") + " " + appointment.time_range_end);

                        editappointment.Calendar_Start_datetime = DateTimeOffset.Parse(cal_startdate.ToString()).UtcDateTime;
                        editappointment.Calendar_End_datetime   = DateTimeOffset.Parse(cal_enddate.ToString()).UtcDateTime;

                        string       timezone   = "West Asia Standard Time";
                        TimeZoneInfo targetZone = TimeZoneInfo.FindSystemTimeZoneById(timezone);
                        cal_startdate = TimeZoneInfo.ConvertTimeFromUtc(cal_startdate, targetZone);
                        cal_enddate   = TimeZoneInfo.ConvertTimeFromUtc(cal_enddate, targetZone);

                        editappointment.Calendar_Start_datetime = cal_startdate;
                        editappointment.Calendar_End_datetime   = cal_enddate;

                        // end

                        // get time into total minutes
                        string startingtime = appointment.time_range_start.ToString();
                        string endindtime   = appointment.time_range_end.ToString();

                        TimeSpan starttime = TimeSpan.Parse(startingtime);
                        TimeSpan endatime  = TimeSpan.Parse(endindtime);

                        TimeSpan Difflength = endatime.Subtract(starttime);                 // difference between start time and end time
                        int      total      = (Difflength.Hours * 60) + Difflength.Minutes; // convert difference in minutes

                        editappointment.length = total;

                        editappointment.client_id          = Convert.ToInt32(appointment.client_id);
                        editappointment.attribute_id       = multipleattribute.ToString();
                        editappointment.emp_id             = Convert.ToInt32(appointment.emp_id);
                        editappointment.work_id            = Convert.ToInt32(appointment.work_id);
                        editappointment.time_interval_id   = Convert.ToInt32(appointment.time_interval_id);
                        editappointment.user_id            = Convert.ToInt32(Session["User_Id"]);
                        dbcon.Entry(editappointment).State = System.Data.Entity.EntityState.Modified;
                        dbcon.SaveChanges();

                        // delete the appointment already inserted days and again insert into another table
                        //SqlConnection appointmentconnection = new SqlConnection(dbcon.connectionString());
                        //var appointmentcommand = new SqlCommand("appooint_day", appointmentconnection);
                        //appointmentcommand.CommandType = CommandType.StoredProcedure;
                        //appointmentcommand.Parameters.AddWithValue("@appointment_id", Convert.ToInt32(appointment.appointment_id));
                        //appointmentcommand.Parameters.AddWithValue("@type", "deleteappointmentday");
                        //appointmentconnection.Open();
                        //SqlDataReader appointmentreader = appointmentcommand.ExecuteReader();
                        //appointmentconnection.Close();

                        SqlConnection connectiondeleteday = new SqlConnection(dbcon.connectionString());
                        var           commanddeleteday    = new SqlCommand("Appointmentday", connectiondeleteday);
                        commanddeleteday.CommandType = CommandType.StoredProcedure;
                        commanddeleteday.Parameters.AddWithValue("@maxid", Convert.ToInt32(0));
                        commanddeleteday.Parameters.AddWithValue("@day", Convert.ToInt32(0));
                        commanddeleteday.Parameters.AddWithValue("@appointmentid", Convert.ToInt32(appointment.appointment_id));
                        commanddeleteday.Parameters.AddWithValue("@type", "deleteday");
                        connectiondeleteday.Open();
                        SqlDataReader rdrdelete = commanddeleteday.ExecuteReader();
                        connectiondeleteday.Close();

                        if (!string.IsNullOrEmpty(multiplevalue))
                        {
                            string[] values = multiplevalue.Split(',');
                            for (int i = 0; i < values.Length; i++)
                            {
                                values[i] = values[i].Trim();

                                SqlConnection connectionupdateday = new SqlConnection(dbcon.connectionString());
                                var           commandupdateday    = new SqlCommand("Appointmentday", connectionupdateday);
                                commandupdateday.CommandType = CommandType.StoredProcedure;
                                commandupdateday.Parameters.AddWithValue("@maxid", Convert.ToInt32(appointment.appointment_id));
                                commandupdateday.Parameters.AddWithValue("@day", Convert.ToInt32(values[i]));
                                commandupdateday.Parameters.AddWithValue("@appointmentid", Convert.ToInt32(0));
                                commandupdateday.Parameters.AddWithValue("@type", "updateday");
                                connectionupdateday.Open();
                                SqlDataReader rdrupdate = commandupdateday.ExecuteReader();
                                connectiondeleteday.Close();
                            }
                        }
                        return(RedirectToAction("Appointment", "Appointment"));
                    }
                }

                catch (DbEntityValidationException ex)
                {
                    foreach (var entityValidationErrors in ex.EntityValidationErrors)
                    {
                        foreach (var validationError in entityValidationErrors.ValidationErrors)
                        {
                            Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                        }
                    }
                    return(View());
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }