Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            QHSEEntities context = new QHSEEntities();

            IIdentity id      = User.Identity;
            dynamic   profile = ProfileBase.Create(id.Name);

            Session["username"] = profile.username;

            if (User.IsInRole("Admin") || User.IsInRole("Sub-Admin"))
            {
                Response.Redirect("~/Admin/ReportList.aspx");
            }
            else if (User.IsInRole("User"))
            {
                Response.Redirect("~/Users/ObservationList.aspx");
            }
            else
            {
                Response.Write("User doesn't have a role, please log in again");
            }
            //else
            //{
            //    Response.Write("User doesn't have a role, please log in again");
            //    Response.Redirect("~/Login.aspx");
            //}
        }
Exemplo n.º 2
0
 public void UpdateObservation(Observation obs)
 {
     try
     {
         using (context = new QHSEEntities())
         {
             Observation observation = context.Observations.Where(x => x.CardId == obs.CardId).First <Observation>();
             observation.Date            = obs.Date;
             observation.Location        = obs.Location;
             observation.Others          = obs.Others;
             observation.Classification  = obs.Classification;
             observation.Description     = obs.Description;
             observation.ImmediateAction = obs.ImmediateAction;
             observation.FurtherAction   = obs.FurtherAction;
             observation.PositiveComment = obs.PositiveComment;
             observation.PhotoPath       = obs.PhotoPath;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw e;
         //}
     }
 }
Exemplo n.º 3
0
 public void UpdateEmployee(Employee emp)
 {
     try
     {
         using (context = new QHSEEntities())
         {
             Employee employee = context.Employees.Where(x => x.UserName == emp.UserName).First <Employee>();
             employee.UserName = emp.UserName;
             employee.Name     = emp.Name;
             if (emp.HRMS != null)
             {
                 employee.HRMS = emp.HRMS;
             }
             employee.Title      = emp.Title;
             employee.Department = emp.Department;
             employee.Email      = emp.Email;
             employee.Role       = emp.Role;
             if (emp.Password != null)
             {
                 employee.Password = emp.Password;
             }
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            QHSEEntities context  = new QHSEEntities();
            string       reportNo = Request.QueryString["ReportNo"];

            List <string> listReportNo = context.Reports.Select(x => x.ReportNo).ToList <string>();

            foreach (string rn in listReportNo)
            {
                if (reportNo != "" && reportNo == rn)
                {
                    r = context.Reports.Where(x => x.ReportNo == reportNo).First();

                    lblReportNo.ForeColor = System.Drawing.Color.Black;
                    lblReportNo.Text      = "Report #: " + r.ReportNo;
                    //DateTime reportDate = r.Date;
                    litDate.Text           = r.Date.ToString("dd/MM/yyyy");
                    litLocation.Text       = r.Location;
                    litClassification.Text = r.Classification;
                    litDescription.Text    = r.Description;

                    if (r.Memo == "")
                    {
                        litMemo.Text = "None";
                    }
                    else
                    {
                        litMemo.Text = r.Memo;
                    }

                    if (r.PhotoPath == "" || r.PhotoPath == null)
                    {
                        imgBtn.Visible = false;
                        lblPhoto.Text  = "No photo attached";
                    }
                    else
                    {
                        FileInfo fileInfo = new FileInfo(r.PhotoPath);
                        imgBtn.ImageUrl = "~/Pictures/" + fileInfo.Name;
                        imgBtn.Width    = Unit.Pixel(150);
                        imgBtn.Height   = Unit.Pixel(100);
                        imgBtn.Style.Add("padding", "5px");
                        imgBtn.Click += new ImageClickEventHandler(imgBtn_Click);
                    }
                    break;
                }

                else
                {
                    lblReportNo.Text      = "Report Not Found!";
                    lblReportNo.ForeColor = System.Drawing.Color.Red;
                    imgBtn.Visible        = false;
                }
            }
        }
Exemplo n.º 5
0
        protected void gvUser_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string username = gvUser.Rows[e.RowIndex].Cells[1].Text;

            string query = "SELECT DISTINCT UserId FROM aspnet_Users WHERE UserName = '******'";

            con = new SqlConnection(conStr);
            SqlDataAdapter adapter = new SqlDataAdapter(query, con);
            DataTable      dt      = new DataTable();

            adapter.Fill(dt);
            //DataSet dataset = new DataSet();
            //adapter.Fill(dataset);

            Guid userId = Guid.Parse(dt.Rows[0][0].ToString());



            using (QHSEEntities context = new QHSEEntities())
            {
                Employee emp = context.Employees.Where(x => x.UserName == username).First <Employee>();
                context.Employees.Remove(emp);

                //aspnet_Profile profile = context.aspnet_Profile.Where(x => x.PropertyValuesString == username).First();
                //context.aspnet_Profile.Remove(profile);

                aspnet_Users user = context.aspnet_Users.Where(x => x.UserName == username).First();
                context.aspnet_Users.Remove(user);

                aspnet_Membership mem = context.aspnet_Membership.Where(x => x.UserId == userId).First();
                context.aspnet_Membership.Remove(mem);

                aspnet_UsersInRoles userInRole = context.aspnet_UsersInRoles.Where(x => x.UserId == userId).First();
                context.aspnet_UsersInRoles.Remove(userInRole);


                context.SaveChanges();
                Response.Redirect("~/Admin/ManageUsers.aspx");
            }
        }
Exemplo n.º 6
0
 public void UpdateReport(Report r)
 {
     try
     {
         using (context = new QHSEEntities())
         {
             Report report = context.Reports.Where(x => x.ReportNo == r.ReportNo).First <Report>();
             report.ReportNo       = r.ReportNo;
             report.Date           = r.Date;
             report.Location       = r.Location;
             report.Classification = r.Classification;
             report.Description    = r.Description;
             report.Memo           = r.Memo;
             if (report.PhotoPath == null)
             {
                 report.PhotoPath = r.PhotoPath;
             }
             else
             {
                 if (r.PhotoPath != null && r.PhotoPath != "")
                 {
                     report.PhotoPath = r.PhotoPath;
                 }
                 else
                 {
                     report.PhotoPath = report.PhotoPath;
                 }
             }
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            QHSEEntities context = new QHSEEntities();
            int          cardId  = Convert.ToInt32(Request.QueryString["CardId"]);

            o = context.Observations.Where(x => x.CardId == cardId).First();

            lblCardId2.Text        = cardId.ToString();
            litDate.Text           = o.Date.ToString("dd/MM/yyyy");
            litLocation.Text       = o.Location;
            litClassification.Text = o.Classification;
            if (o.Description == "")
            {
                litDescription.Text = "N/A";
            }
            else
            {
                litDescription.Text = o.Description;
            }

            if (o.ImmediateAction == "")
            {
                litImmAction.Text = "N/A";
            }
            else
            {
                litImmAction.Text = o.ImmediateAction;
            }

            if (o.FurtherAction == "")
            {
                litFurtherAction.Text = "N/A";
            }
            else
            {
                litFurtherAction.Text = o.FurtherAction;
            }

            if (o.PositiveComment == "")
            {
                litComment.Text = "N/A";
            }
            else
            {
                litComment.Text = o.PositiveComment;
            }

            if (o.PhotoPath == "" || o.PhotoPath == null)
            {
                imgBtn.Visible = false;
                lblPhoto.Text  = "No photo attached";
            }
            else
            {
                FileInfo fileInfo = new FileInfo(o.PhotoPath);
                imgBtn.ImageUrl = "~/Pictures/" + fileInfo.Name;
                imgBtn.Width    = Unit.Pixel(150);
                imgBtn.Height   = Unit.Pixel(100);
                imgBtn.Style.Add("padding", "5px");
                imgBtn.Click += new ImageClickEventHandler(imgBtn_Click);
            }
        }