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());
     }
 }
 public ActionResult Create_Worktype(juggle.Models.tbl_worktype work_type)
 {
     using (jugglecontext dbcon = new jugglecontext())
     {
         try
         {
             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.user_id      = Convert.ToInt32(Session["User_Id"]);
             worktype.created_date = DateTime.Now;
             dbcon.tbl_worktype.Add(worktype);
             dbcon.SaveChanges();
             return(RedirectToAction("Work_type", "Work_type"));
         }
         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(work_type));
         }
     }
 }
        public ActionResult employee_delete(Int32 emp_id)
        {
            using (jugglecontext dbcon = new jugglecontext())
            {
                if (Session["User_Id"] != null)
                {
                    // when employee delete at that time his/her assigned appointment will be upassign
                    SqlConnection connection = new SqlConnection(dbcon.connectionString());
                    var           command    = new SqlCommand("[updatedata]", connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@emp_id", emp_id);
                    command.Parameters.AddWithValue("@startdate", 0);
                    command.Parameters.AddWithValue("@enddate", 0);
                    command.Parameters.AddWithValue("@StartTime", 0);
                    command.Parameters.AddWithValue("@endTime", 0);
                    command.Parameters.AddWithValue("@user_id", Convert.ToInt32(Session["User_Id"]));
                    command.Parameters.AddWithValue("@attribute_id", 0);
                    command.Parameters.AddWithValue("@client_id", 0);
                    command.Parameters.AddWithValue("@appointment_id", 0);
                    command.Parameters.AddWithValue("@StatementType", "emp_data");
                    connection.Open();
                    SqlDataReader rdr = command.ExecuteReader();

                    tbl_employee_info objEmpl = dbcon.tbl_employee_info.Find(emp_id);
                    dbcon.tbl_employee_info.Remove(objEmpl);
                    dbcon.SaveChanges();
                }
                return(RedirectToAction("Employee", "Employee"));
            }
        }
Example #4
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());
        }
        public ActionResult Create_Workers(tbl_user user)
        {
            var autopassword = "";

            if (Session["User_Id"] != null)
            {
                int getstatusID = Convert.ToInt32(Request.Form["Status_hidden"]);
                if (getstatusID == 0)
                {
                    getstatusID = 1;
                }
                using (jugglecontext dbcon = new jugglecontext())
                {
                    try
                    {
                        var      userId = Convert.ToInt32(Session["User_Id"]);
                        tbl_user tblusr = new tbl_user();
                        tblusr.firstName     = user.firstName.Trim();
                        tblusr.lastName      = user.lastName.Trim();
                        tblusr.address       = user.address.Trim();
                        tblusr.phoneno       = user.phoneno.Trim();
                        tblusr.email         = user.email.Trim();
                        tblusr.username      = user.username.Trim();
                        autopassword         = dbcon.GeneratePassword(6).Trim();
                        tblusr.password      = dbcon.Encrypt(autopassword.Trim());
                        tblusr.created_date  = DateTime.Now;
                        tblusr.status        = getstatusID;
                        tblusr.supervisor_id = userId;
                        tblusr.role_id       = 3;
                        tblusr.user_id       = userId;
                        dbcon.tbl_user.Add(tblusr);
                        dbcon.SaveChanges();

                        string Password = autopassword;
                        string Body     = "Your password '" + Password + "' ";
                        dbcon.SendMail(tblusr.email, "Password", Body, Password);

                        return(RedirectToAction("ManageWorkers", "Workers"));
                    }
                    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(user));
                    }
                }
            }
            else
            {
                return(View(user));
            }
        }
        public ActionResult Worktype_delete(Int32 work_id)
        {
            if (Session["User_Id"] != null)
            {
                try
                {
                    using (jugglecontext dbcon = new jugglecontext())
                    {
                        if (Session["User_Id"] != null)
                        {
                            string workid          = work_id.ToString();
                            var    employee_detail = (from a in dbcon.tbl_employee_info
                                                      where a.emp_qualifiedservicetypes.Contains(workid)
                                                      select a).ToList();

                            for (int i = 0; i < employee_detail.Count; i++)
                            {
                                string emp_worktype = employee_detail[i].emp_qualifiedservicetypes.ToString();
                                emp_worktype = emp_worktype.Replace(workid, "");
                                SqlConnection connection = new SqlConnection(dbcon.connectionString());
                                var           command    = new SqlCommand("[updatedata]", connection);
                                command.CommandType = CommandType.StoredProcedure;
                                command.Parameters.AddWithValue("@client_id", 0);
                                command.Parameters.AddWithValue("@attribute_id", emp_worktype);
                                command.Parameters.AddWithValue("@appointment_id", 0);
                                command.Parameters.AddWithValue("@StatementType", "worktype_data");
                                command.Parameters.AddWithValue("@emp_id", Convert.ToInt32(employee_detail[i].emp_id));
                                command.Parameters.AddWithValue("@startdate", 0);
                                command.Parameters.AddWithValue("@enddate", 0);
                                command.Parameters.AddWithValue("@StartTime", 0);
                                command.Parameters.AddWithValue("@endTime", 0);
                                command.Parameters.AddWithValue("@user_id", Convert.ToInt32(Session["User_Id"]));
                                connection.Open();
                                SqlDataReader rdr = command.ExecuteReader();
                            }

                            tbl_worktype objEmp = dbcon.tbl_worktype.Find(work_id);
                            dbcon.tbl_worktype.Remove(objEmp);
                            dbcon.SaveChanges();
                        }
                        return(RedirectToAction("Work_type", "Work_type"));
                    }
                }
                catch
                {
                    return(View());
                }
            }
            else
            {
                return(View("Login", "Account"));
            }
        }
Example #7
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"));
            }
        }
Example #8
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());
        }
        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());
        }
Example #10
0
 public ActionResult Employeeavailibility_delete(Int32 empavailability_id)
 {
     if (Session["User_Id"] != null)
     {
         try
         {
             using (jugglecontext dbcon = new jugglecontext())
             {
                 if (Session["User_Id"] != null)
                 {
                     //var empavailability_detail = (from a in dbcon.tbl_employee_availability
                     //                              where a.empavailability_id == empavailability_id
                     //                              select a).ToList();
                     //// when employee delete at that time his/her assigned appointment will be upassign
                     //SqlConnection connection = new SqlConnection(dbcon.connectionString());
                     //var command = new SqlCommand("[updatedata]", connection);
                     //command.CommandType = CommandType.StoredProcedure;
                     //command.Parameters.AddWithValue("@startdate", Convert.ToDateTime(empavailability_detail[0].start_date));
                     //command.Parameters.AddWithValue("@enddate", Convert.ToDateTime(empavailability_detail[0].end_date));
                     //command.Parameters.AddWithValue("@StartTime", empavailability_detail[0].time_range_start.ToString());
                     //command.Parameters.AddWithValue("@endTime", empavailability_detail[0].time_range_end.ToString());
                     //command.Parameters.AddWithValue("@user_id", Convert.ToInt32(Session["User_Id"]));
                     //command.Parameters.AddWithValue("@emp_id", Convert.ToInt32(empavailability_detail[0].emp_id));
                     //command.Parameters.AddWithValue("@attribute_id", 0);
                     //command.Parameters.AddWithValue("@client_id", 0);
                     //command.Parameters.AddWithValue("@appointment_id", 0);
                     //command.Parameters.AddWithValue("@StatementType", "emp_data");
                     //connection.Open();
                     //SqlDataReader rdr = command.ExecuteReader();
                     tbl_employee_availability objEmp = dbcon.tbl_employee_availability.Find(empavailability_id);
                     dbcon.tbl_employee_availability.Remove(objEmp);
                     dbcon.SaveChanges();
                 }
                 return(RedirectToAction("EmployeeAvailability", "EmployeeAvailability"));
             }
         }
         catch
         {
             return(View());
         }
     }
     else
     {
         return(View("Login", "Account"));
     }
 }
Example #11
0
        public ActionResult Delete_Workers(Int32 user_id)
        {
            using (jugglecontext dbcon = new jugglecontext())
            {
                if (Session["User_Id"] != null)
                {
                    tbl_user objworker = dbcon.tbl_user.Find(user_id);
                    dbcon.tbl_user.Remove(objworker);
                    dbcon.SaveChanges();
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }

                return(RedirectToAction("ManageWorkers", "Workers"));
            }
        }
Example #12
0
 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 Create_Worktype_Category(juggle.Models.tbl_worktype_category work_type_category)
 {
     using (jugglecontext dbcon = new jugglecontext())
     {
         try
         {
             tbl_worktype_category worktype = new tbl_worktype_category();
             worktype.worktypecategory_name = work_type_category.worktypecategory_name.Trim();
             worktype.created_date          = DateTime.Now;
             dbcon.tbl_worktype_category.Add(worktype);
             dbcon.SaveChanges();
             return(RedirectToAction("Worktype_category", "Work_Type_Category"));
         }
         catch (Exception ex)
         {
             return(View(work_type_category));
         }
     }
 }
Example #14
0
 public ActionResult Worktype_delete(Int32 work_id)
 {
     try
     {
         using (jugglecontext dbcon = new jugglecontext())
         {
             if (Session["User_Id"] != null)
             {
                 tbl_worktype objEmp = dbcon.tbl_worktype.Find(work_id);
                 dbcon.tbl_worktype.Remove(objEmp);
                 dbcon.SaveChanges();
             }
             return(RedirectToAction("Worktype", "Worktype"));
         }
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
Example #15
0
 public ActionResult Client_delete(Int32 client_id)
 {
     try
     {
         using (jugglecontext dbcon = new jugglecontext())
         {
             if (Session["User_Id"] != null)
             {
                 tbl_client objclient = dbcon.tbl_client.Find(client_id);
                 dbcon.tbl_client.Remove(objclient);
                 dbcon.SaveChanges();
             }
             return(RedirectToAction("Client", "Client"));
         }
     }
     catch
     {
         return(View());
     }
 }
Example #16
0
        public ActionResult Create_attribute(tbl_attribute_data attribute)
        {
            if (Session["User_Id"] != null)
            {
                using (jugglecontext dbcon = new jugglecontext())
                {
                    tbl_attribute_data data_attribute = new tbl_attribute_data();
                    data_attribute.attribute_name = attribute.attribute_name;
                    data_attribute.created_date   = DateTime.Now;
                    data_attribute.user_id        = Convert.ToInt32(Session["User_Id"]);
                    dbcon.tbl_attribute_data.Add(data_attribute);
                    dbcon.SaveChanges();
                    return(RedirectToAction("attribute", "Attribute"));
                }
            }

            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());
     }
 }
        public ActionResult Create_Employee(tbl_employee_info employee)
        {
            using (jugglecontext dbcon = new jugglecontext())
            {
                try
                {
                    string            multipleattribute = Request.Form["attribute_id_multiple"].ToString();
                    string            multipleService   = Request.Form["emp_qualifiedservicetypes_multiple"].ToString();
                    var               getButton         = HttpContext.Request.Form["Create"];
                    tbl_employee_info empl = new tbl_employee_info();
                    empl.emp_firstname             = employee.emp_firstname.Trim();
                    empl.emp_lastname              = employee.emp_lastname.Trim();
                    empl.emp_contactinfo           = employee.emp_contactinfo.Trim();
                    empl.emp_qualifiedservicetypes = multipleService;
                    empl.created_date              = DateTime.Now;
                    empl.user_id              = Convert.ToInt32(Session["User_Id"]);
                    empl.emp_code             = autogenerateid();
                    empl.attribute_id         = multipleattribute;
                    empl.emp_googlecalendarID = employee.emp_googlecalendarID;
                    empl.emp_note             = employee.emp_note;
                    empl.emp_transportion     = employee.emp_transportion;
                    empl.emp_password         = dbcon.Encrypt(employee.emp_password);
                    dbcon.tbl_employee_info.Add(empl);
                    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);
                        }
                    }

                    return(View(employee));
                }
            }
        }
Example #19
0
 public ActionResult Create_Worktype(juggle.Models.tbl_worktype work_type)
 {
     using (jugglecontext dbcon = new jugglecontext())
     {
         try
         {
             tbl_worktype worktype = new tbl_worktype();
             worktype.name           = work_type.name.Trim();
             worktype.color          = work_type.color.Trim();
             worktype.worktypecat_id = Convert.ToInt32(work_type.worktypecat_id);
             worktype.user_id        = Convert.ToInt32(Session["User_Id"]);
             worktype.created_date   = DateTime.Now;
             dbcon.tbl_worktype.Add(worktype);
             dbcon.SaveChanges();
             return(RedirectToAction("Worktype", "Worktype"));
         }
         catch (Exception ex)
         {
             return(View(work_type));
         }
     }
 }
Example #20
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());
     }
 }
 public ActionResult appointment_delete(Int32 appointment_id)
 {
     try
     {
         using (jugglecontext dbcon = new jugglecontext())
         {
             if (Session["User_Id"] != null)
             {
                 tbl_appointment objEmp = dbcon.tbl_appointment.Find(appointment_id);
                 dbcon.tbl_appointment.Remove(objEmp);
                 dbcon.SaveChanges();
                 return(RedirectToAction("Appointment", "Appointment"));
             }
             else
             {
                 return(RedirectToAction("Login", "Account"));
             }
         }
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Delete_Supervisor(Int32 user_id)
 {
     using (jugglecontext dbcon = new jugglecontext())
     {
         try
         {
             if (Session["User_Id"] != null)
             {
                 tbl_user objuser = dbcon.tbl_user.Find(user_id);
                 dbcon.tbl_user.Remove(objuser);
                 dbcon.SaveChanges();
             }
             else
             {
                 return(RedirectToAction("Login", "Account"));
             }
         }
         catch (Exception ex)
         {
             Logfile.WriteCDNLog(ex.ToString(), "Delete supervisor");
         }
         return(RedirectToAction("ManageSupervisors", "Supervisors"));
     }
 }
Example #23
0
        public ActionResult Create_Client(tbl_client Client)
        {
            if (Session["User_Id"] != null)
            {
                try
                {
                    using (jugglecontext dbcon = new jugglecontext())
                    {
                        var getButton = HttpContext.Request.Form["Save"];
                        if (getButton == "Save")
                        {
                            string multipleattribute = Request.Form["attribute_id_multiple"].ToString();
                            {
                                var getScheduleId = Request.Form["schedule_hidden"];
                                var x_lat         = 0.0;
                                var y_long        = 0.0;
                                var clientnote    = string.Empty;

                                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;
                                }

                                tbl_client tblClient = new tbl_client();
                                tblClient.client_firstname     = Client.client_firstname;
                                tblClient.client_lastname      = Client.client_lastname;
                                tblClient.client_companyname   = Client.client_companyname;
                                tblClient.client_secondaryname = Client.client_secondaryname;
                                tblClient.client_email         = Client.client_email;
                                tblClient.client_code          = autogenerateid();
                                tblClient.client_contact_info  = Client.client_contact_info;
                                tblClient.client_address       = Client.client_address;
                                if (!string.IsNullOrEmpty(Client.client_note))
                                {
                                    tblClient.client_note = Client.client_note;
                                }
                                else
                                {
                                    tblClient.client_note = "N/A";
                                }
                                tblClient.x_lat        = x_lat;
                                tblClient.y_long       = y_long;
                                tblClient.attribute_id = multipleattribute.ToString();
                                tblClient.created_date = DateTime.Now;
                                tblClient.user_id      = Convert.ToInt32(Session["User_Id"]);
                                dbcon.tbl_client.Add(tblClient);
                                dbcon.SaveChanges();
                                return(RedirectToAction("Client", "Client"));
                            }
                        }
                        else
                        {
                        }
                        return(View());
                    }
                }
                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(Client));
                }
            }

            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Example #24
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 Create_Appointment(juggle.Models.tbl_appointment appointment)
        {
            if (Session["User_Id"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            using (jugglecontext dbcon = new jugglecontext())
            {
                try
                {
                    tbl_appointment addappointment    = new tbl_appointment();
                    string          multipleattribute = Request.Form["attribute_idmul"].ToString();
                    string          multiplelist      = null;

                    if (appointment.recurring)
                    {
                        multiplelist = Request.Form["multiple"];
                    }
                    else
                    {
                        multiplelist = null;
                    }
                    addappointment.created_date = DateTime.Now;
                    addappointment.description  = appointment.description;
                    addappointment.recurring    = appointment.recurring;

                    if (!string.IsNullOrEmpty(multiplelist))
                    {
                        addappointment.day = multiplelist;
                    }
                    else
                    {
                        multiplelist = "0"; addappointment.day = "0";
                    }

                    //addappointment.day = appointment.day;
                    addappointment.start_date       = appointment.start_date;
                    addappointment.end_date         = appointment.end_date;
                    addappointment.time_range_start = appointment.time_range_start;
                    addappointment.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);

                    addappointment.Calendar_Start_datetime = DateTimeOffset.Parse(cal_startdate.ToString()).UtcDateTime;
                    addappointment.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);

                    addappointment.Calendar_Start_datetime = cal_startdate;
                    addappointment.Calendar_End_datetime   = cal_enddate;

                    // end
                    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);
                    int      total      = (Difflength.Hours * 60) + Difflength.Minutes;

                    addappointment.length = total;
                    if (!string.IsNullOrEmpty(addappointment.notes))
                    {
                        addappointment.notes = appointment.notes;
                    }
                    else
                    {
                        addappointment.notes = "N/A";
                    }

                    addappointment.client_id        = Convert.ToInt32(appointment.client_id);
                    addappointment.work_id          = Convert.ToInt32(appointment.work_id);
                    addappointment.time_interval_id = Convert.ToInt32(appointment.time_interval_id);
                    addappointment.user_id          = Convert.ToInt32(Session["User_Id"]);

                    addappointment.attribute_id = multipleattribute.ToString();
                    addappointment.time         = appointment.time;
                    dbcon.tbl_appointment.Add(addappointment);
                    dbcon.SaveChanges();
                    var maxid = 0;
                    try
                    {
                        var context_latest_Id = new jugglecontext();

                        var maxappointmentid = (from a in context_latest_Id.tbl_appointment
                                                select new
                        {
                            a.appointment_id
                        }).ToList();

                        maxid = Convert.ToInt32(maxappointmentid[0].appointment_id);

                        for (int i = 0; i < maxappointmentid.Count; i++)
                        {
                            if (maxid < Convert.ToInt32(maxappointmentid[i].appointment_id))
                            {
                                maxid = Convert.ToInt32(maxappointmentid[i].appointment_id);
                            }
                        }
                    }
                    catch { }

                    if (!string.IsNullOrEmpty(multiplelist))
                    {
                        string[] values = multiplelist.Split(',');

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

                        for (int i = 0; i < values.Length; i++)
                        {
                            values[i] = values[i].Trim();

                            // add day into another table
                            SqlConnection connectioninsertday = new SqlConnection(dbcon.connectionString());
                            var           commandinsertday    = new SqlCommand("Appointmentday", connectioninsertday);
                            commandinsertday.CommandType = CommandType.StoredProcedure;
                            commandinsertday.Parameters.AddWithValue("@maxid", Convert.ToInt32(maxid));
                            commandinsertday.Parameters.AddWithValue("@day", Convert.ToInt32(values[i]));
                            commandinsertday.Parameters.AddWithValue("@appointmentid", Convert.ToInt32(0));
                            //commandinsertday.Parameters.AddWithValue("@date", dating);
                            commandinsertday.Parameters.AddWithValue("@type", "insertday");
                            connectioninsertday.Open();
                            SqlDataReader rdr = commandinsertday.ExecuteReader();
                            connectioninsertday.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(appointment));
                }
            }
        }
        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"));
            }
        }
        public ActionResult Create_Supervisor(tbl_user user)
        {
            var autopassword = "";

            if (Session["User_Id"] != null)
            {
                using (jugglecontext dbcon = new jugglecontext())
                {
                    try
                    {
                        var getButton = HttpContext.Request.Form["Save"];
                        if (getButton == "Save")
                        {
                            {
                                int getstatusID = Convert.ToInt32(Request.Form["Status_hidden"]);
                                if (getstatusID == 0)
                                {
                                    getstatusID = 1;
                                }

                                var status = from p in dbcon.tbl_status
                                             select new { p.status_id, p.status };

                                var statusname = status.ToList().Select(c => new SelectListItem
                                {
                                    Text  = c.status.ToString(),
                                    Value = c.status_id.ToString(),
                                }).ToList();

                                ViewBag.status = statusname;
                                var      userId = Convert.ToInt32(Session["User_Id"]);
                                tbl_user tblusr = new tbl_user();
                                tblusr.firstName     = user.firstName.Trim();
                                tblusr.lastName      = user.lastName.Trim();
                                tblusr.address       = user.address;
                                tblusr.phoneno       = user.phoneno.Trim();
                                tblusr.email         = user.email.Trim();
                                tblusr.username      = user.username.Trim();
                                autopassword         = dbcon.GeneratePassword(6);
                                tblusr.password      = dbcon.Encrypt(autopassword.Trim());
                                tblusr.supervisor_id = userId;
                                tblusr.created_date  = DateTime.Now;

                                tblusr.timezoneid       = "Central Standard Time";
                                tblusr.status           = user.status;
                                tblusr.role_id          = 2;
                                tblusr.user_id          = 0;
                                Session["firstname"]    = user.firstName;
                                Session["profile_pict"] = user.profile_pict;
                                if (Request.Files.Count > 0)
                                {
                                    var file = Request.Files[0];

                                    if (file != null && file.ContentLength > 0)
                                    {
                                        var fileName = Path.GetFileName(file.FileName);
                                        var path     = Path.Combine(Server.MapPath("~/Profile_Picture/"), fileName);
                                        file.SaveAs(path);
                                        tblusr.profile_pict = fileName;
                                    }
                                    else
                                    {
                                        tblusr.profile_pict = "Noimage.png";
                                    }
                                }

                                dbcon.tbl_user.Add(tblusr);
                                dbcon.SaveChanges();

                                string Body = "Hello, \nYour Username: "******" \nPassword: "******" \n\n for login in Juggle Click this Link to login  \n " + dbcon.redirectUrl() + "";
                                dbcon.SendMail(tblusr.email, "Login Credntials for Juggle", Body, tblusr.username, autopassword);

                                return(RedirectToAction("ManageSupervisors", "Supervisors"));
                            }
                        }
                        else
                        {
                        }
                    }
                    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(user));
                    }
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
            return(View(user));
        }
Example #28
0
        public ActionResult attribute_delete(Int32 atrribute_id)
        {
            try
            {
                using (jugglecontext dbcon = new jugglecontext())
                {
                    if (Session["User_Id"] != null)
                    {
                        string atrributeid = atrribute_id.ToString();
                        // when delete attribute then remove that attribute from the appointment, client,employee
                        var client_detail = (from a in dbcon.tbl_client
                                             where a.attribute_id.Contains(atrributeid)
                                             select a).ToList();

                        var employee_detail = (from a in dbcon.tbl_employee_info
                                               where a.attribute_id.Contains(atrributeid)
                                               select a).ToList();

                        var appointment_detail = (from a in dbcon.tbl_appointment
                                                  where a.attribute_id.Contains(atrributeid)
                                                  select a).ToList();

                        for (int i = 0; i < client_detail.Count; i++)
                        {
                            string client_attri = client_detail[i].attribute_id.ToString();
                            client_attri = client_attri.Replace(atrributeid, "");
                            SqlConnection connection = new SqlConnection(dbcon.connectionString());
                            var           command    = new SqlCommand("[updatedata]", connection);
                            command.CommandType = CommandType.StoredProcedure;
                            command.Parameters.AddWithValue("@client_id", Convert.ToInt32(client_detail[i].client_id));
                            command.Parameters.AddWithValue("@attribute_id", client_attri);
                            command.Parameters.AddWithValue("@appointment_id", 0);
                            command.Parameters.AddWithValue("@StatementType", "attribute_data");
                            command.Parameters.AddWithValue("@emp_id", 0);
                            command.Parameters.AddWithValue("@startdate", 0);
                            command.Parameters.AddWithValue("@enddate", 0);
                            command.Parameters.AddWithValue("@StartTime", 0);
                            command.Parameters.AddWithValue("@endTime", 0);
                            command.Parameters.AddWithValue("@user_id", Convert.ToInt32(Session["User_Id"]));
                            connection.Open();
                            SqlDataReader rdr = command.ExecuteReader();
                        }

                        for (int i = 0; i < employee_detail.Count; i++)
                        {
                            string emp_attri = employee_detail[i].attribute_id.ToString();
                            emp_attri = emp_attri.Replace(atrributeid, "");
                            SqlConnection connection = new SqlConnection(dbcon.connectionString());
                            var           command    = new SqlCommand("[updatedata]", connection);
                            command.CommandType = CommandType.StoredProcedure;
                            command.Parameters.AddWithValue("@client_id", 0);
                            command.Parameters.AddWithValue("@attribute_id", emp_attri);
                            command.Parameters.AddWithValue("@StatementType", "attribute_data");
                            command.Parameters.AddWithValue("@appointment_id", 0);
                            command.Parameters.AddWithValue("@emp_id", employee_detail[i].emp_id);
                            command.Parameters.AddWithValue("@startdate", 0);
                            command.Parameters.AddWithValue("@enddate", 0);
                            command.Parameters.AddWithValue("@StartTime", 0);
                            command.Parameters.AddWithValue("@endTime", 0);
                            command.Parameters.AddWithValue("@user_id", Convert.ToInt32(Session["User_Id"]));
                            connection.Open();
                            SqlDataReader rdr = command.ExecuteReader();
                        }

                        for (int i = 0; i < appointment_detail.Count; i++)
                        {
                            string appointment_attri = appointment_detail[i].attribute_id.ToString();
                            appointment_attri = appointment_attri.Replace(atrributeid, "");
                            SqlConnection connection = new SqlConnection(dbcon.connectionString());
                            var           command    = new SqlCommand("[updatedata]", connection);
                            command.CommandType = CommandType.StoredProcedure;
                            command.Parameters.AddWithValue("@client_id", 0);
                            command.Parameters.AddWithValue("@attribute_id", appointment_attri);
                            command.Parameters.AddWithValue("@StatementType", "attribute_data");
                            command.Parameters.AddWithValue("@appointment_id", appointment_detail[i].appointment_id);
                            command.Parameters.AddWithValue("@emp_id", 0);
                            command.Parameters.AddWithValue("@startdate", 0);
                            command.Parameters.AddWithValue("@enddate", 0);
                            command.Parameters.AddWithValue("@StartTime", 0);
                            command.Parameters.AddWithValue("@endTime", 0);
                            command.Parameters.AddWithValue("@user_id", Convert.ToInt32(Session["User_Id"]));
                            connection.Open();
                            SqlDataReader rdr = command.ExecuteReader();
                        }
                        tbl_attribute_data objEmp = dbcon.tbl_attribute_data.Find(atrribute_id);
                        dbcon.tbl_attribute_data.Remove(objEmp);
                        dbcon.SaveChanges();
                    }
                    return(RedirectToAction("attribute", "Attribute"));
                }
            }
            catch
            {
                return(View());
            }
        }