예제 #1
0
        protected void Reset_Click(object sender, EventArgs e)
        {
            user users = new user();

            Support user_model = new Support();

            List<string> all_users = (from x in user_model.users select x.username).ToList();
            var valid = (from v in user_model.users
                         where v.username == decoded_username
                         select v).FirstOrDefault();

            if (valid.password == Password.Text)
            {

                if (NewPassword.Text == ConfirmPassword.Text)
                {

                    valid.password = ConfirmPassword.Text;
                    user_model.SaveChanges();
                    if (HttpContext.Current.Request.Cookies["user"] != null)
                    {
                        HttpCookie aCookie = HttpContext.Current.Request.Cookies["user"];
                        aCookie.Expires = DateTime.Now.AddDays(-10);
                        aCookie.Value = "";
                        HttpContext.Current.Response.Cookies.Add(aCookie);
                    }
                    Response.Redirect("~/Account/ResetPasswordConfirmation");
                    return;
                }
            }
            else
            {
                ErrorMessage.Text = "Wrong Password";
            }
        }
        //submit
        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            try
            {
                using (Support support = new Support())
                {
                    //role_model target = (from x in support.Roles
                    //                    where x.id == id
                    //                    select x).FirstOrDefault();

                    //desc = detailrole_edit_desc.Text;
                    //note = detailrole_edit_note.Text;

                    //target.descrpition = desc;
                    //target.note = note;

                    //support.SaveChanges();
                }

                Response.Redirect(prevPage);
            }
            catch (System.Exception ex)
            {
                Response.Write(ex);
            }
        }
예제 #3
0
 protected void detailmodel_name_TextChanged(object sender, EventArgs e)
 {
     Support support = new Support();
     var model = (from m in support.models
                  where m.id == id
                  select m).FirstOrDefault();
     model.name = detailmodel_name.Text;
     support.SaveChanges();
 }
예제 #4
0
        protected void detailmodel_interface_SelectedIndexChanged(object sender, EventArgs e)
        {
            Support support = new Support();
            var model = (from m in support.models
                         where m.id == id
                         select m).FirstOrDefault();

            model._interface = Convert.ToInt32(detailmodel_interface.Text);
            support.SaveChanges();
        }
예제 #5
0
 protected void detailmodel_cord_TextChanged(object sender, EventArgs e)
 {
     Support support = new Support();
     var model = (from m in support.models
                  where m.id == id
                  select m).FirstOrDefault();
     if (!String.IsNullOrEmpty(detailmodel_cord.Text))
     {
         model.cord = detailmodel_cord.Text;
         support.SaveChanges();
     }
 }
예제 #6
0
 protected void detailperson2_delete_Click(object sender, EventArgs e)
 {
     using (Support p = new Support())
     {
         var target = (from x in p.people
                       where x.id == id
                       select x).FirstOrDefault();
         p.people.Remove(target);
         p.SaveChanges();
     }
     Response.Redirect(prevPage);
 }
예제 #7
0
        protected void detailmodel_delete_Click(object sender, EventArgs e)
        {
            using (Support s = new Support())
            {
                var target = (from x in s.models
                              where x.id == id
                              select x).FirstOrDefault();
                s.models.Remove(target);
                s.SaveChanges();
            }

            Response.Redirect("~/Admin/Model");
        }
예제 #8
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Support support = new Support();
            var file = from a in support.Files
                       where a.id == id
                       select new
                       {
                           a.incident,
                           a.action
                       };

            int ac = file.FirstOrDefault().action;
            int inc = file.FirstOrDefault().incident;
            Response.Redirect("/Detail/DetailAction2" + "?id=" + ac + "&case_id=" + inc);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            id = Convert.ToInt32(Request.QueryString["id"]);

               if (!IsPostBack)
               {
               if (prevPage == String.Empty)
               {
                   prevPage = Request.UrlReferrer.ToString();
               }
               try
               {
                   Support support = new Support();
                   //var roles = from r in support.Roles
                   //            where r.id == id
                   //            select new
                   //            {
                   //                r.descrpition,
                   //                r.note,
                   //            };

                   ////name
                   //if (!String.IsNullOrEmpty(roles.FirstOrDefault().descrpition))
                   //{
                   //    detailrole_edit_desc.Text = roles.FirstOrDefault().descrpition.ToString();
                   //}
                   //else
                   //{
                   //    detailrole_edit_desc.Text = "No description...";
                   //}

                   ////name
                   //if (!String.IsNullOrEmpty(roles.FirstOrDefault().note))
                   //{
                   //    detailrole_edit_note.Text = roles.FirstOrDefault().note.ToString();
                   //}
                   //else
                   //{
                   //    detailrole_edit_desc.Text = "No note...";
                   //}

                  }
               catch (Exception ex)
               {
                   Response.Write(ex);
               }
               }
        }
예제 #10
0
 protected void detailfile2_name_TextChanged(object sender, EventArgs e)
 {
     try
     {
         using (Support support = new Support())
         {
             var name = (from c in support.Files
                         where c.id == id
                         select c).FirstOrDefault();
             name.name = detailfile2_name.Text;
             support.SaveChanges();
         }
     }
     catch (System.Exception ex)
     {
         Response.Write(ex);
     }
 }
예제 #11
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                try
                {
                    Support support = new Support();
                    int rid = Convert.ToInt32(e.Row.Cells[0].Text);

                    if (Request.Cookies["user"] != null)
                    {
                        string QueryString = "~/Detail/DetailCase2.aspx?id=" + rid;
                        string NavigateURL = ResolveUrl(QueryString);
                        e.Row.Attributes.Add("onClick", string.Format("window.open('{0}', '_newtab')", NavigateURL));
                        e.Row.Style.Add("cursor", "pointer");
                    }
                    //actnum.ToList().ForEach(x => Response.Write(x.Key + ":" + x.Value + " "));
                    //action
                    //Response.Write(rid);
                    //List<int> all_actions = (from x in support.Actions select x.incident).ToList();
                    if (!actnum.ContainsKey(rid))
                    {
                        e.Row.Cells[4].Text = "N/A";
                    }
                    else
                    {
                        e.Row.Cells[4].Text = actnum[rid].ToString();
                    }

                    e.Row.Cells[0].Visible = false;
                }

                catch (Exception ex)
                {
                    Response.Write(ex);
                }
            }

            if (e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[0].Visible = false;
            }
        }
예제 #12
0
        protected void detailperson2_email_TextChanged(object sender, EventArgs e)
        {
            try
            {
                using (Support personnel = new Support())
                {
                    person target = (from x in personnel.people
                                     where x.id == id
                                     select x).FirstOrDefault();

                    target.email = detailperson2_email.Text;
                    personnel.SaveChanges();
                }
            }
            catch (System.Exception ex)
            {
                Response.Write(ex);
            }
        }
예제 #13
0
        //active
        protected void detailperson2_active_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (Support personnel = new Support())
            {
                person target = (from x in personnel.people
                                 where x.id == id
                                 select x).FirstOrDefault();

                if (detailperson2_active.SelectedValue == "0")
                {
                    target.ed = new DateTime(3000, 1, 1);
                }
                else if (detailperson2_active.SelectedValue == "1")
                {
                    target.ed = DateTime.Now;
                }

                personnel.SaveChanges();
            }
        }
예제 #14
0
        //submit
        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            try
            {
                role role = new role()
               {
                   name = detailrole_name.Text,
                   description = detailrole_desc.Text,

               };

                Support p = new Support();
                p.roles.Add(role);
                p.SaveChanges();

                Response.Redirect(prevPage);
            }
            catch (System.Exception ex)
            {
                Response.Write(ex);
            }
        }
예제 #15
0
        ////edit
        //protected void Unnamed_Click(object sender, EventArgs e)
        //{
        //    detailorg2_submit.Visible = true;
        //    detailorg2_cancel.Visible = true;
        //    detailorg2_name.ReadOnly = false;
        //    detailorg2_desc.ReadOnly = false;
        //}
        ////submit
        //protected void detailorg2_submit_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        using (Support personnel = new Support())
        //        {
        //            org target = (from x in personnel.orgs
        //                                where x.id == id
        //                                select x).FirstOrDefault();
        //            target.name = detailorg2_name.Text;
        //            target.description = detailorg2_desc.Text;
        //            personnel.SaveChanges();
        //        }
        //        detailorg2_name.ReadOnly = true;
        //        detailorg2_desc.ReadOnly = true;
        //        detailorg2_submit.Visible = false;
        //        detailorg2_cancel.Visible = false;
        //    }
        //    catch (System.Exception ex)
        //    {
        //        Response.Write(ex);
        //    }
        //}
        ////cancel
        //protected void detailorg2_cancel_Click(object sender, EventArgs e)
        //{
        //    detailorg2_name.ReadOnly = true;
        //    detailorg2_desc.ReadOnly = true;
        //    detailorg2_submit.Visible = false;
        //    detailorg2_cancel.Visible = false;
        //    detailorg2_name.Text = name;
        //    detailorg2_desc.Text = desc;
        //}
        protected void detailorg2_delete_Click(object sender, EventArgs e)
        {
            using (Support p = new Support())
            {
                List<org> orgs = p.orgs.ToList();

                var target = (from x in p.orgs
                              where x.id == id
                              select x).FirstOrDefault();
                foreach(org o in orgs)
                {
                    if (o.parent == target.id)
                    {
                        Response.Write("This department has child department, to delete, please delete child department first...");
                        return;
                    }
                }
                p.orgs.Remove(target);
                p.SaveChanges();
            }
            Response.Redirect(prevPage);
        }
예제 #16
0
        public CalActs()
        {
            Support s = new Support();
            List<Incident> cases = new List<Incident>();
            foreach (Incident i in s.Incidents.ToList())
            {
                int counter = 0;

                foreach (action_model a in s.Actions.ToList())
                {
                    if (a.incident == i.id)
                        counter += 1;
                }

                Node no = new Node(counter, null);
                if (i.parent != null)
                {
                    no.parent = i.parent;
                }
                caselist.Add(no);
            }
        }
예제 #17
0
        //delete
        protected void detailafile2_delete_Click(object sender, EventArgs e)
        {
            using (Support s = new Support())
            {
                var target = (from x in s.Files
                              where x.id == id
                              select x).FirstOrDefault();
                s.Files.Remove(target);
                s.SaveChanges();
            }

            //SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
            //string parentURL = currentNode.ParentNode.Url;
            //using (Support s = new Support())
            //{
            //    var target = (from x in s.Files
            //                  where x.id == id
            //                  select x).FirstOrDefault();

            //    Response.Redirect("/Detail/DetailAction2" + "?id=" + _action + "&case_id=" + _incident);
            //}
            Response.Redirect(prevPage);
        }
예제 #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["user"] != null)
            {
                string decoded_username = Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(Request.Cookies["user"]["username"]), "ProtectCookieUsername"));
                string decoded_role = Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(Request.Cookies["user"]["role"]), "ProtectCookieRole"));

                if (decoded_role == "admin")
                {

                }

                else
                {
                    Response.Redirect("~/");
                }
            }

            else
            {
                Response.Redirect("~/");
            }

            id = Convert.ToInt32(Request.QueryString["id"]);

            if (!IsPostBack)
            {
                if (prevPage == String.Empty)
                {
                    prevPage = Request.UrlReferrer.ToString();
                }

                try
                {
                    Support personnel = new Support();
                    var roles = from r in personnel.roles
                                where r.id == id
                                select new
                                {
                                    r.name,
                                    r.description,
                                };

                    //name
                    if (roles.FirstOrDefault().name != null)
                    {
                        name = roles.FirstOrDefault().name.ToString();
                        detailrole2_name.Text = name;
                    }
                    else
                    {
                        detailrole2_name.Text = "No name...";
                        name = "No name...";
                    }

                    //description
                    if (roles.FirstOrDefault().description != null)
                    {
                        desc = roles.FirstOrDefault().description.ToString();
                        detailrole2_description.Text = desc;
                    }
                    else
                    {
                        detailrole2_description.Text = "No description...";
                        desc = "No description...";
                    }

                }
                catch (Exception ex)
                {
                    Response.Write(ex);
                }
            }
        }
예제 #19
0
        protected void detailaction2_file_gridview_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string QueryString = "~/Detail/DetailFile2.aspx?id=" + e.Row.Cells[1].Text;
                string NavigateURL = ResolveUrl(QueryString);
                e.Row.Attributes.Add("onClick", string.Format("window.open('{0}')", NavigateURL));
                e.Row.Style.Add("cursor", "pointer");

                int s = Convert.ToInt32(e.Row.Cells[3].Text);

                //Response.Write(s);
                try
                {
                    using (Support support = new Support())
                    {
                        List<int> all_members = (from x in support.members select x.id).ToList();
                        if (all_members.Contains(s))
                        {
                            var sen = (from p in support.people
                                       join m in support.members
                                       on p.id equals m.person
                                       where m.id == s
                                       select p).FirstOrDefault();
                            e.Row.Cells[3].Text = sen.lastname + sen.firstname;
                            //Response.Write(sen.lastname);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    Response.Write(ex);
                }

                e.Row.Cells[1].Visible = false;
            }

            if (e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[1].Visible = false;
            }
        }
예제 #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["user"] != null)
            {
                string decoded_username = Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(Request.Cookies["user"]["username"]), "ProtectCookieUsername"));
                string decoded_role = Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(Request.Cookies["user"]["role"]), "ProtectCookieRole"));

                if (decoded_role == "admin")
                {

                }

                else
                {
                    Response.Redirect("~/");
                }
            }

            else
            {
                Response.Redirect("~/");
            }

            id = Convert.ToInt32(Request.QueryString["id"]);

            if (!IsPostBack)
            {
                if (prevPage == String.Empty)
                {
                    prevPage = Request.UrlReferrer.ToString();
                }

                try
                {
                    Support personnel = new Support();
                    var person = from p in personnel.people
                                 where p.id == id
                                 select new
                                 {
                                     p.firstname,
                                     p.sd,
                                     p.ed,
                                     p.lastname,
                                     p.phone,
                                     p.email
                                 };

                    //last name
                    if (!String.IsNullOrEmpty(person.FirstOrDefault().lastname))
                    {
                        lastname = person.FirstOrDefault().lastname.ToString();
                        detailperson2_lastname.Text = lastname;
                    }
                    else
                    {
                        detailperson2_lastname.Text = "No name...";
                    }

                    //first name
                    if (!String.IsNullOrEmpty(person.FirstOrDefault().firstname))
                    {
                        firstname = person.FirstOrDefault().firstname.ToString();
                        detailperson2_firstname.Text = firstname;
                    }
                    else
                    {
                        detailperson2_firstname.Text = "No name...";
                    }

                    //Phone
                    if (!String.IsNullOrEmpty(person.FirstOrDefault().phone))
                    {
                        phone = person.FirstOrDefault().phone.ToString();
                        detailperson2_phone.Text = phone;
                    }
                    else
                    {
                        phone = "No phone...";
                        detailperson2_phone.Text = phone;
                    }

                    //Email
                    if (!String.IsNullOrEmpty(person.FirstOrDefault().email))
                    {
                        email = person.FirstOrDefault().email.ToString();
                        detailperson2_email.Text = email;
                    }
                    else
                    {
                        email = "No email...";
                        detailperson2_email.Text = email;
                    }

                    //start date
                    if (person.FirstOrDefault().sd != null)
                    {
                        detailperson2_start_date.Text = person.FirstOrDefault().sd.ToString("MM/dd/yyyy");
                    }
                    else
                    {
                        detailperson2_start_date.Text = "No...";
                    }

                    //detactive
                    if (person.FirstOrDefault().ed < DateTime.Now)
                    {
                        detailperson2_active.SelectedValue = "1";
                    }
                    else
                    {
                        detailperson2_active.SelectedValue = "0";
                    }

                }
                catch (Exception ex)
                {
                    Response.Write(ex);
                }
            }
        }
예제 #21
0
 protected void detailaction2_receiver_TextChanged(object sender, EventArgs e)
 {
     try
     {
         using (Support support = new Support())
         {
             var receiver = (from c in support.Actions
                             where c.id == id
                             select c).FirstOrDefault();
             receiver.receiver = detailaction2_receiver.Text;
             support.SaveChanges();
         }
     }
     catch (System.Exception ex)
     {
         Response.Write(ex);
     }
 }
예제 #22
0
        SiteMapNode SiteMap_File(object sender, SiteMapResolveEventArgs e)
        {
            SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
            if (currentNode.Url == "/")
            {
                return currentNode;
            }

            using (Support s = new Support())
            {
                var target = (from x in s.Files
                              where x.id == id
                              select x).FirstOrDefault();

                currentNode.ParentNode.Url = "/Detail/DetailAction2" + "?id=" + _action + "&case_id=" + _incident;
                //Response.Write(currentNode.ParentNode.Url);
                return currentNode;
            }
        }
예제 #23
0
        protected void detailAction2_sender_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (detailaction2_sender.SelectedValue == "")
            {
                return;
            }

            try
            {
                using (Support support = new Support())
                {
                    var se = (from c in support.Actions
                              where c.id == id
                              select c).FirstOrDefault();
                    se.sender = Convert.ToInt32(detailaction2_sender.SelectedValue.ToString());
                    support.SaveChanges();
                }
            }
            catch (System.Exception ex)
            {
                Response.Write(ex);
            }
        }
예제 #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["user"] != null)
            {
                string decoded_username = Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(Request.Cookies["user"]["username"]), "ProtectCookieUsername"));
                string decoded_role = Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(Request.Cookies["user"]["role"]), "ProtectCookieRole"));

                if (decoded_role == "admin" || decoded_role == "support")
                {

                }

                else
                {
                    Response.Redirect("~/");
                }
            }

            else
            {
                Response.Redirect("~/");
            }

            int isNew = Convert.ToInt32(Request.QueryString["new"]);
            if (!String.IsNullOrEmpty(Request.QueryString["id"]))
            {
                id = Convert.ToInt32(Request.QueryString["id"]);
                //Response.Write(id);
            }
            _incident = Convert.ToInt32(Request.QueryString["incident"]);
            _action = Convert.ToInt32(Request.QueryString["action"]);
            _sender = Convert.ToInt32(Request.QueryString["sender"]);

            if (!IsPostBack)
            {

                if (prevPage == String.Empty)
                {
                    prevPage = Request.UrlReferrer.ToString();
                }

                SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(SiteMap_File);
                if (isNew == 1)
                {
                    file_model fi = new file_model()
                    {
                        action = _action,
                        incident = _incident,
                        sender = _sender,
                        dt = DateTime.Now,
                        name = "change it",
                    };

                    Support s = new Support();
                    s.Files.Add(fi);
                    s.SaveChanges();
                    id = fi.id;
                    detailfile2_date.Text = fi.dt.ToString("MM/dd/yyyy");
                    Support support = new Support();
                    var sen = (from p in support.people
                               join m in support.members
                               on p.id equals m.person
                               where m.id == fi.sender
                               select p).FirstOrDefault();
                    detailfile2_sender.Text = sen.lastname + sen.firstname;
                    var p_query = from p in support.Incidents where p.id == fi.incident select p;
                    detailfile2_case.Text = p_query.FirstOrDefault().description;
                }
                else
                {

                    try
                    {
                        Support support = new Support();
                        Support personnel = new Support();
                        var file = from a in support.Files
                                   where a.id == id
                                   select new
                                   {
                                       a.incident,
                                       a.name,
                                       a.sender,
                                       a.fpath,
                                       a.note,
                                       a.dt,
                                       a.action
                                   };

                        _action = file.FirstOrDefault().action;
                        _incident = file.FirstOrDefault().incident;
                        //date
                        if (file.FirstOrDefault().dt != null)
                        {
                            detailfile2_date.Text = file.FirstOrDefault().dt.ToString("MM/dd/yyyy");
                        }
                        else
                        {
                            detailfile2_date.Text = "No date...";
                        }

                        //name
                        if (!String.IsNullOrEmpty(file.FirstOrDefault().name))
                        {
                            name = file.FirstOrDefault().name.ToString();
                            detailfile2_name.Text = name;
                        }
                        else
                        {
                            name = "No name...";
                            detailfile2_name.Text = name;
                        }

                        //case
                        List<int> all_cases = (from x in support.Incidents select x.id).ToList();
                        if (!all_cases.Contains(Convert.ToInt32(file.FirstOrDefault().incident.ToString())))
                        {
                            detailfile2_case.Text = "No case...";
                        }
                        else
                        {
                            var p_query = from p in support.Incidents where p.id == file.FirstOrDefault().incident select p;
                            detailfile2_case.Text = p_query.FirstOrDefault().description;
                        }

                        //sender
                        List<int> all_members = (from x in personnel.members select x.id).ToList();
                        if (!all_members.Contains(Convert.ToInt32(file.FirstOrDefault().sender.ToString())))
                        {
                            detailfile2_sender.Text = "No sender...";
                        }
                        else
                        {
                            int s = Convert.ToInt32(file.FirstOrDefault().sender.ToString());
                            var sename = from r in personnel.people
                                         join m in personnel.members
                                         on r.id equals m.person
                                         where m.id == s
                                         select r;
                            detailfile2_sender.Text = sename.FirstOrDefault().lastname + " " + sename.FirstOrDefault().firstname;
                        }

                        //path
                        if (!String.IsNullOrEmpty(file.FirstOrDefault().fpath))
                        {
                            path = file.FirstOrDefault().fpath.ToString();
                            detailfile2_path.Text = path;
                        }
                        else
                        {
                            path = "No path...";
                            detailfile2_path.Text = path;
                        }

                        //note
                        if (!String.IsNullOrEmpty(file.FirstOrDefault().note))
                        {
                            note = file.FirstOrDefault().note.ToString();
                            detailfile2_note.Text = note;
                        }
                        else
                        {
                            note = "No note...";
                            detailfile2_note.Text = note;
                        }

                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex);
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            id = Convert.ToInt32(Request.QueryString["id"]);

            detailperson_edit_organization.AppendDataBoundItems = true;
            detailperson_edit_prev_person.AppendDataBoundItems = true;

            //to avoid duplication in dropdown lists
            if (IsPostBack)
            {
                detailperson_edit_organization.DataSourceID = "";
                Items.Clear();
                detailperson_edit_prev_person.DataSourceID = "";
                Items.Clear();
            }

            if (!IsPostBack)
            {
                if (prevPage == String.Empty)
                {
                    prevPage = Request.UrlReferrer.ToString();
                }

                try
                {
                    Support support = new Support();
                    //var person = from c in support.People
                    //             where c.id == id
                    //             select new
                    //             {
                    //                 c.name,
                    //                 c.sd,
                    //                 c.ed,
                    //                 c.org,
                    //                 c.prev
                    //             };

                    ////get all actions for later use
                    //List<int> all_orgs = (from x in support.orgs select x.id).ToList();
                    //List<int> all_person = (from x in support.People select x.id).ToList();

                    ////name
                    //if (!String.IsNullOrEmpty(person.FirstOrDefault().name))
                    //{
                    //    detailperson_edit_name.Text = person.FirstOrDefault().name.ToString();
                    //}
                    //else
                    //{
                    //    detailperson_edit_name.Text = "No name...";
                    //}

                    ////start date
                    //if (person.FirstOrDefault().sd.HasValue)
                    //{
                    //    detailperson_edit_startdate.SelectedDate = DateTime.Parse(person.FirstOrDefault().sd.ToString());
                    //    detailperson_edit_startdate.VisibleDate = DateTime.Parse(person.FirstOrDefault().sd.ToString());
                    //}
                    //else
                    //{
                    //    detailperson_edit_startdate.SelectedDate = DateTime.Now;
                    //    detailperson_edit_startdate.VisibleDate = DateTime.Now;
                    //}

                    ////end date
                    //if (person.FirstOrDefault().ed.HasValue)
                    //{
                    //    detailperson_edit_enddate.SelectedDate = DateTime.Parse(person.FirstOrDefault().ed.ToString());
                    //    detailperson_edit_enddate.VisibleDate = DateTime.Parse(person.FirstOrDefault().ed.ToString());
                    //}
                    //else
                    //{
                    //    detailperson_edit_enddate.SelectedDate = DateTime.Now;
                    //    detailperson_edit_enddate.VisibleDate = DateTime.Now;
                    //}

                    ////org
                    //if (person.FirstOrDefault().org != null)
                    //{
                    //    if (!all_orgs.Contains(Convert.ToInt32(person.FirstOrDefault().org.ToString())))
                    //    {
                    //        detailperson_edit_organization.Text = "";
                    //    }
                    //    else
                    //    {
                    //        detailperson_edit_organization.SelectedValue = person.FirstOrDefault().org.ToString();
                    //    }
                    //}
                    //else
                    //{
                    //    detailperson_edit_organization.Text = "";
                    //}

                    ////parent
                    //if (person.FirstOrDefault().prev != null)
                    //{
                    //    if (!all_person.Contains(Convert.ToInt32(person.FirstOrDefault().prev.ToString())))
                    //    {
                    //        detailperson_edit_prev_person.Text = "";
                    //    }
                    //    else
                    //    {
                    //        detailperson_edit_prev_person.SelectedValue = person.FirstOrDefault().prev.ToString();
                    //    }
                    //}
                    //else
                    //{
                    //    detailperson_edit_prev_person.Text = "";
                    //}

                    ////phone
                    //if (!String.IsNullOrEmpty(person.FirstOrDefault().name))
                    //{
                    //    detailperson_edit_name.Text = person.FirstOrDefault().name.ToString();
                    //}
                    //else
                    //{
                    //    detailperson_edit_name.Text = "No name...";
                    //}

                    ////email
                    //if (!String.IsNullOrEmpty(person.FirstOrDefault().name))
                    //{
                    //    detailperson_edit_name.Text = person.FirstOrDefault().name.ToString();
                    //}
                    //else
                    //{
                    //    detailperson_edit_name.Text = "No name...";
                    //}

                }
                catch (Exception ex)
                {
                    Response.Write(ex);
                }
            }
        }
        protected void Unnamed4_Click(object sender, EventArgs e)
        {
            try
            {
                using (Support support = new Support())
                {
                    //person_model target = (from x in support.People
                    //                       where x.id == id
                    //                       select x).FirstOrDefault();

                    //target.name = detailperson_edit_name.Text;
                    //target.sd = detailperson_edit_startdate.SelectedDate;
                    //target.ed = detailperson_edit_enddate.SelectedDate;

                    //if (detailperson_edit_organization.SelectedValue == "")
                    //{
                    //    target.org = null;
                    //}
                    //else
                    //{
                    //    target.org = Convert.ToInt32(detailperson_edit_organization.SelectedValue.ToString());
                    //}

                    //if (detailperson_edit_prev_person.SelectedValue == "")
                    //{
                    //    target.prev = null;
                    //}
                    //else
                    //{
                    //    target.prev = Convert.ToInt32(detailperson_edit_prev_person.SelectedValue.ToString());
                    //}

                    //support.SaveChanges();
                }

                Response.Redirect(prevPage);
            }
            catch (System.Exception ex)
            {
                Response.Write(ex);
            }
        }
예제 #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //to avoid duplication in dropdown lists
            if (IsPostBack)
            {
                detailaction2_sender.DataSourceID = "";
                Items.Clear();
            }

            if (Request.Cookies["user"] != null)
            {
                string decoded_username = Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(Request.Cookies["user"]["username"]), "ProtectCookieUsername"));
                string decoded_role = Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(Request.Cookies["user"]["role"]), "ProtectCookieRole"));
                person_id = Convert.ToInt32(Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(Request.Cookies["user"]["person"]), "ProtectCookiePerson")));
                case_id = Convert.ToInt32(Request.QueryString["case_id"]);

                if (decoded_role == "admin" || decoded_role == "support")
                {

                }

                else
                {
                    Response.Redirect("~/");
                }
            }

            else
            {
                Response.Redirect("~/");
            }

            if (!String.IsNullOrEmpty(Request.QueryString["id"]))
            {
                id = Convert.ToInt32(Request.QueryString["id"]);
            }

            int isNew = Convert.ToInt32(Request.QueryString["new"]);

            if (!IsPostBack)
            {

                SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(SiteMap_SiteMapResolve);
                if (isNew == 1)
                {
                    action_model action = new action_model()
                    {
                        dt = DateTime.Now,
                        incident = case_id,
                        description = "default"
                    };

                    Support s = new Support();
                    s.Actions.Add(action);
                    s.SaveChanges();
                    id = action.id;
                    detailaction2_date.Text = action.dt.ToString("MM/dd/yyyy");

                    Support support = new Support();
                    var p_query = from p in support.Incidents where p.id == action.incident select p;
                    detailaction2_case.Text = p_query.FirstOrDefault().description;
                }
                else
                {
                    try
                    {
                        Support support = new Support();
                        Support personnel = new Support();
                        var action = from a in support.Actions
                                     where a.id == id
                                     select new
                                     {
                                         a.incident,
                                         a.receiver,
                                         a.sender,
                                         a.description,
                                         a.dt
                                     };

                        //date
                        if (action.FirstOrDefault().dt != null)
                        {
                            detailaction2_date.Text = action.FirstOrDefault().dt.ToString("MM/dd/yyyy");
                        }
                        else
                        {
                            detailaction2_date.Text = "No date...";
                        }

                        //description
                        if (String.IsNullOrEmpty(action.FirstOrDefault().description) || action.FirstOrDefault().description == "default")
                        {
                            detailaction2_desc.Text = "";
                        }
                        else
                        {
                            desc = action.FirstOrDefault().description.ToString();
                            detailaction2_desc.Text = desc;
                        }

                        //case
                        List<int> all_cases = (from x in support.Incidents select x.id).ToList();
                        if (!all_cases.Contains(Convert.ToInt32(action.FirstOrDefault().incident.ToString())))
                        {
                            detailaction2_case.Text = "No case...";
                        }
                        else
                        {
                            var p_query = from p in support.Incidents where p.id == action.FirstOrDefault().incident select p;
                            detailaction2_case.Text = p_query.FirstOrDefault().description;
                        }

                        //sender
                        List<int> all_members = (from x in personnel.members select x.id).ToList();
                        if (!all_members.Contains(Convert.ToInt32(action.FirstOrDefault().sender.ToString())))
                        {
                            detailaction2_sender.SelectedValue = "";
                        }
                        else
                        {
                            int s = Convert.ToInt32(action.FirstOrDefault().sender.ToString());
                            detailaction2_sender.SelectedValue = action.FirstOrDefault().sender.ToString();
                        }

                        //receiver
                        if (!String.IsNullOrEmpty(action.FirstOrDefault().receiver))
                        {
                            detailaction2_receiver.Text = action.FirstOrDefault().receiver.ToString();
                        }
                        else
                        {
                            // detailaction2_desc.Text = desc;
                        }

                        ////receiver
                        //if (!all_members.Contains(Convert.ToInt32(action.FirstOrDefault().receiver.ToString())))
                        //{
                        //    detailaction2_receiver.Text = "No receiver...";
                        //}
                        //else
                        //{
                        //    int s = Convert.ToInt32(action.FirstOrDefault().receiver.ToString());
                        //    var rename = from r in personnel.people
                        //                 join m in personnel.members
                        //                 on r.id equals m.person
                        //                 where m.id == s
                        //                 select r;
                        //    detailaction2_receiver.Text = rename.FirstOrDefault().lastname + " " + rename.FirstOrDefault().firstname;
                        //}

                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex);
                    }
                }

            }
            detailaction2_sender.AppendDataBoundItems = true;
        }
예제 #28
0
        ////edit
        //protected void Unnamed_Click(object sender, EventArgs e)
        //{
        //    detailaction2_cancel.Visible = true;
        //    detailaction2_submit.Visible = true;
        //    detailaction2_desc.ReadOnly = false;
        //}
        //submit
        //protected void detailaction2_submit_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        using (Support support = new Support())
        //        {
        //            action_model target = (from x in support.Actions
        //                                 where x.id == id
        //                                 select x).FirstOrDefault();
        //            target.description = detailaction2_desc.Text;
        //            support.SaveChanges();
        //        }
        //        detailaction2_desc.ReadOnly = true;
        //        detailaction2_submit.Visible = false;
        //        detailaction2_cancel.Visible = false;
        //    }
        //    catch (System.Exception ex)
        //    {
        //        Response.Write(ex);
        //    }
        //}
        ////cancel
        //protected void detailaction2_cancel_Click(object sender, EventArgs e)
        //{
        //    detailaction2_desc.ReadOnly = true;
        //    detailaction2_submit.Visible = false;
        //    detailaction2_cancel.Visible = false;
        //    detailaction2_desc.Text = desc;
        //}
        //delete
        protected void detailaction2_delete_Click(object sender, EventArgs e)
        {
            using (Support s = new Support())
            {
                var target = (from x in s.Actions
                              where x.id == id
                              select x).FirstOrDefault();
                s.Actions.Remove(target);
                s.SaveChanges();
            }

            SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
            string parentURL = currentNode.ParentNode.Url;
            Response.Redirect(parentURL);
        }
예제 #29
0
        protected void Action_gridview_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //Get the LinkButton control in the first cell
                LinkButton _doubleClickButton = (LinkButton)e.Row.Cells[0].Controls[0].FindControl("ActionDoubleClick");
                //Get the javascript which is assigned to this LinkButton
                string _jsDouble =
                ClientScript.GetPostBackClientHyperlink(_doubleClickButton, "");
                //Add this JavaScript to the ondblclick Attribute of the row
                e.Row.Attributes["ondblclick"] = _jsDouble;

                try
                {
                    Support support = new Support();
                    int rid = Convert.ToInt32(e.Row.Cells[1].Text);
                    var actions = from a in support.Actions
                                where a.id == rid
                                select new
                                {
                                    a.incident
                                };

                    //incident
                    List<int> all_incidents = (from x in support.Incidents select x.id).ToList();
                    if (!all_incidents.Contains(Convert.ToInt32(actions.FirstOrDefault().incident.ToString())))
                    {
                        e.Row.Cells[3].Text = "No incidents...";
                    }
                    else
                    {
                        int i = actions.FirstOrDefault().incident;
                        var p_query = from p in support.Incidents where p.id == i select p;
                        e.Row.Cells[3].Text = p_query.FirstOrDefault().description;
                    }
                    e.Row.Cells[1].Visible = false;
                }

                catch (Exception ex)
                {
                    Response.Write(ex);
                }
            }

            if (e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[1].Visible = false;
            }
        }
예제 #30
0
        protected void detailrole2_description_TextChanged(object sender, EventArgs e)
        {
            try
            {
                using (Support personnel = new Support())
                {
                    role target = (from x in personnel.roles
                                   where x.id == id
                                   select x).FirstOrDefault();

                    target.description = detailrole2_description.Text;
                    personnel.SaveChanges();

                }
            }
            catch (System.Exception ex)
            {
                Response.Write(ex);
            }
        }