Ejemplo n.º 1
0
        public SegmentDetail GetSegmentDetail(HtmlNode segmentDetailNode)
        {
            var segmentDetail = new SegmentDetail();

            var mainSection     = segmentDetailNode.GetChildById("contentAreaInnerMain");
            var seriesNode      = mainSection.GetChildById("lblSeries");
            var titleNode       = mainSection.GetChildById("lblTitle");
            var authorNamesNode = mainSection.GetChildById("lblAuthors").SelectSingleNode(".//h3");
            var descriptionNode = mainSection.GetChildById("lblDescription").SelectSingleNode(".//p");
            var authorsNode     = mainSection.SelectSingleNode("./div[@class='sectionBottom']").SelectSingleNode("./blockquote");

            segmentDetail.Series      = seriesNode.DecodeHtml();
            segmentDetail.Title       = titleNode.DecodeHtml();
            segmentDetail.Description = descriptionNode != null?descriptionNode.DecodeHtml() : "";

            segmentDetail.AuthorNames = authorNamesNode != null?authorNamesNode.DecodeHtml() : "";

            segmentDetail.Authors = GetSegmentAuthors(authorsNode);

            return(segmentDetail);
        }
Ejemplo n.º 2
0
        private void CommandPaste(int ParentSegmentDetailID)
        {
            try
            {
                SegmentDetail cutSegmentDetail = (SegmentDetail)Session["SelectedSegmentDetail"];

                List <SegmentDetail> data   = (List <SegmentDetail>)Session["SegmentDetailsData"];
                SegmentDetail        parent = new SegmentDetail()
                {
                    ParentDetailID = ParentSegmentDetailID
                };
                do
                {
                    parent = data.Where(x => x.SegmentDetailID == parent.ParentDetailID).FirstOrDefault();
                    if (parent == null || parent.SegmentDetailID == cutSegmentDetail.SegmentDetailID)
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "You can not paste a parent under its child");
                        return;
                    }
                } while (parent.ParentDetailID != 0);

                cutSegmentDetail.ParentDetailID = ParentSegmentDetailID;
                new SegmentDetailsDAL().UpdateSegmentDetail(cutSegmentDetail);
                SelectedNodes = (List <int>)Session["SelectedNodes"];
                if (!SelectedNodes.Contains(ParentSegmentDetailID))
                {
                    if (((List <SegmentDetailTreeHelper>)Session["SegmentDetailsTree"]).Where(x => x.SegmentDetailID == ParentSegmentDetailID).FirstOrDefault().ChildCount > 0)
                    {
                        SelectedNodes.Add(ParentSegmentDetailID);
                    }
                }
                Session["SelectedNodes"] = SelectedNodes;
                GetData();
                CreateTreeData();
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }
Ejemplo n.º 3
0
 private void CommandEdit()
 {
     try
     {
         SegmentDetail objSegmentDetail = (SegmentDetail)Session["SelectedSegmentDetail"];
         tbCode.Text             = objSegmentDetail.DetailCode;
         tbDesc.Text             = objSegmentDetail.DetailDesc;
         ddlStatus.SelectedIndex = -1;
         if (objSegmentDetail.Status != null)
         {
             ddlStatus.Items.FindByValue(new Helper().GetItemStatusEnumName(Convert.ToChar(objSegmentDetail.Status))).Selected = true;
         }
         else
         {
             ddlStatus.SelectedIndex = 0;
         }
     }
     catch (Exception ex)
     {
         ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
     }
 }
Ejemplo n.º 4
0
 private void MakeRoot()
 {
     try
     {
         SegmentDetail cutSegmentDetail = (SegmentDetail)Session["SelectedSegmentDetail"];
         cutSegmentDetail.ParentDetailID = 0;
         new SegmentDetailsDAL().UpdateSegmentDetail(cutSegmentDetail);
         SelectedNodes = (List <int>)Session["SelectedNodes"];
         if (!SelectedNodes.Contains(cutSegmentDetail.SegmentDetailID))
         {
             if (((List <SegmentDetailTreeHelper>)Session["SegmentDetailsTree"]).Where(x => x.SegmentDetailID == cutSegmentDetail.SegmentDetailID).FirstOrDefault().ChildCount > 0)
             {
                 SelectedNodes.Add(cutSegmentDetail.SegmentDetailID);
             }
         }
         Session["SelectedNodes"] = SelectedNodes;
         GetData();
         CreateTreeData();
     }
     catch (Exception ex)
     {
         ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
     }
 }
Ejemplo n.º 5
0
        public void SegmentDetailsFileUpload(DataSet ds, ref List <object> ListExcluded)
        {
            object ReturnObj = new object();

            List <string> lstErrors = new List <string>();
            DataTable     dt        = new DataTable();

            dt = new ReportHelper().Validate <SegmentDetailImport>(ds, ((Segment)HttpContext.Current.Session["SelectedSegment"]).ShapeFormat, ref lstErrors);

            if (lstErrors.Count == 0)
            {
                List <SegmentDetail> SegmentDetailData = (List <SegmentDetail>)HttpContext.Current.Session["SegmentDetailsData"];
                List <SegmentDetail> UploadedData      = new ReportHelper().DataTableToList <SegmentDetailImport>(dt).Select(x => new SegmentDetail()
                {
                    SegmentID  = ((Segment)HttpContext.Current.Session["SelectedSegment"]).SegmentID,
                    DetailCode = x.DetailCode,
                    DetailDesc = x.DetailDesc,
                    Status     = ((x.Status == "Active") ? "A" : "D")
                }).ToList();

                if (UploadedData.Count > 0)
                {
                    foreach (SegmentDetail item in UploadedData)
                    {
                        SegmentDetail objSegmentDetail = new SegmentDetail();

                        if (SegmentDetailData.Where(x => x.DetailCode == item.DetailCode).Count() > 0)
                        {
                            ReturnObj = new
                            {
                                status  = "Error",
                                message = "Segment Details **" + item.DetailCode + "** already exists. It`ll be excluded."
                            };
                        }
                        else
                        {
                            objSegmentDetail.SegmentID         = item.SegmentID;
                            objSegmentDetail.DetailCode        = item.DetailCode;
                            objSegmentDetail.DetailDesc        = item.DetailDesc;
                            objSegmentDetail.Status            = item.Status;
                            objSegmentDetail.ParentDetailID    = 0;
                            objSegmentDetail.CreatedBy         = new UsersDAL().GetValidUser(HttpContext.Current.User.Identity.Name).UserID;
                            objSegmentDetail.CreatedTimeStamp  = DateTime.Now;
                            objSegmentDetail.ModifiedBy        = new UsersDAL().GetValidUser(HttpContext.Current.User.Identity.Name).UserID;
                            objSegmentDetail.ModifiedTimeStamp = DateTime.Now;

                            if (new SegmentDetailsDAL().InsertSegmentDetail(objSegmentDetail))
                            {
                                ReturnObj = new
                                {
                                    status  = "Success",
                                    message = "Segment Details **" + item.DetailCode + "** uploaded successfully"
                                };
                            }
                            else
                            {
                                ReturnObj = new
                                {
                                    status  = "Failure",
                                    message = "An error occurred while uploading Segment Details"
                                };
                            }
                        }

                        ListExcluded.Add(ReturnObj);
                    }
                }
            }
            else
            {
                ListExcluded.Add(ReturnObj = new
                {
                    status  = "Error",
                    message = lstErrors.Aggregate((a, b) => a + "<br/>" + b)
                });
            }
        }
Ejemplo n.º 6
0
        protected void gvSegmentDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                List <SegmentDetailTreeHelper> TreeData = (List <SegmentDetailTreeHelper>)Session["SegmentDetailsTree"];
                GridViewRow selectedRow     = gvSegmentDetails.Rows[Convert.ToInt32(e.CommandArgument)];
                int         SegmentDetailID = Convert.ToInt32(gvSegmentDetails.DataKeys[selectedRow.RowIndex]["SegmentDetailID"]);
                if (e.CommandName == "Expand")
                {
                    SelectedNodes = (List <int>)Session["SelectedNodes"];
                    if (!SelectedNodes.Contains(SegmentDetailID))
                    {
                        if (TreeData.Where(x => x.SegmentDetailID == SegmentDetailID).FirstOrDefault().ChildCount > 0)
                        {
                            SelectedNodes.Add(SegmentDetailID);
                        }
                    }
                    else
                    {
                        SelectedNodes.Remove(SegmentDetailID);
                    }
                    CreateTreeData();
                }
                else if (e.CommandName == "AddItem")
                {
                    ChangeSeletedNodeStyle(selectedRow);
                    ChangePageMode(Helper.PageMode.New);
                    EditForm.Visible = true;
                    tbCode.Enabled   = true;
                }
                else if (e.CommandName == "AddChild")
                {
                    ClearPageData();
                    ChangeSeletedNodeStyle(selectedRow);
                    AssignSelectedNode(SegmentDetailID);
                    ChangePageMode(Helper.PageMode.New);
                    EditForm.Visible = true;
                    tbCode.Enabled   = true;
                }
                else if (e.CommandName == "MakeRoot")
                {
                    ChangeSeletedNodeStyle(selectedRow);
                    AssignSelectedNode(SegmentDetailID);
                    MakeRoot();
                    ClearPageData();
                }
                else if (e.CommandName == "CmdEdit")
                {
                    ChangeSeletedNodeStyle(selectedRow);
                    AssignSelectedNode(SegmentDetailID);
                    CommandEdit();
                    ChangePageMode(Helper.PageMode.Edit);
                    EditForm.Visible = true;
                    tbCode.Enabled   = false;
                }
                else if (e.CommandName == "CmdDelete")
                {
                    AssignSelectedNode(SegmentDetailID);
                    SegmentDetail objSegmentDetail = (SegmentDetail)Session["SelectedSegmentDetail"];
                    objSegmentDetail.Status            = "D";
                    objSegmentDetail.ModifiedBy        = LoggedInUser.UserID;
                    objSegmentDetail.ModifiedTimeStamp = DateTime.Now;

                    if (new SegmentDetailsDAL().UpdateSegmentDetail(objSegmentDetail))
                    {
                        ((SiteMaster)this.Master).ShowMessage("Success", "Segment Detail updated successfully");
                    }
                    else
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while updating Segment Detail");
                    }
                    ClearPageData();
                    Session["SelectedSegmentDetail"] = null;
                    GetData();
                    CreateTreeData();
                }
                else if (e.CommandName == "CmdCut")
                {
                    ChangeSeletedNodeStyle(selectedRow);
                    AssignSelectedNode(SegmentDetailID);
                }
                else if (e.CommandName == "CmdPaste")
                {
                    CommandPaste(SegmentDetailID);
                    GetData();
                    CreateTreeData();
                }
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }
Ejemplo n.º 7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                SegmentDetail objSegmentDetail = new SegmentDetail();
                objSegmentDetail.SegmentID  = ((Segment)Session["SelectedSegment"]).SegmentID;
                objSegmentDetail.DetailCode = tbCode.Text.Trim();
                objSegmentDetail.DetailDesc = tbDesc.Text.Trim();
                objSegmentDetail.Status     = new Helper().GetItemStatusEnumValueByName(ddlStatus.SelectedValue);
                if ((SegmentDetail)Session["SelectedSegmentDetail"] == null)
                {
                    objSegmentDetail.ParentDetailID = 0;
                }
                else
                {
                    objSegmentDetail.ParentDetailID = ((SegmentDetail)Session["SelectedSegmentDetail"]).SegmentDetailID;
                }

                if (((Helper.PageMode)Session["PageMode"]) == Helper.PageMode.New)
                {
                    if (new SegmentDetailsDAL().GetSegmentDetails(((Segment)Session["SelectedSegment"]).SegmentID)
                        .Where(x => x.DetailCode.ToUpper().Trim() == tbCode.Text.ToUpper().Trim()).Count() > 0)
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "SegmentDetail already exists");
                        return;
                    }

                    objSegmentDetail.CreatedBy         = LoggedInUser.UserID;
                    objSegmentDetail.CreatedTimeStamp  = DateTime.Now;
                    objSegmentDetail.ModifiedBy        = LoggedInUser.UserID;
                    objSegmentDetail.ModifiedTimeStamp = DateTime.Now;

                    if (new SegmentDetailsDAL().InsertSegmentDetail(objSegmentDetail))
                    {
                        ((SiteMaster)this.Master).ShowMessage("Success", "Segment Detail saved successfully");
                    }
                    else
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while saving Segment Detail");
                    }
                }
                else if (((Helper.PageMode)Session["PageMode"]) == Helper.PageMode.Edit)
                {
                    objSegmentDetail.ModifiedBy        = LoggedInUser.UserID;
                    objSegmentDetail.ModifiedTimeStamp = DateTime.Now;

                    objSegmentDetail.SegmentDetailID = ((SegmentDetail)Session["SelectedSegmentDetail"]).SegmentDetailID;
                    objSegmentDetail.ParentDetailID  = ((SegmentDetail)Session["SelectedSegmentDetail"]).ParentDetailID;

                    if (new SegmentDetailsDAL().UpdateSegmentDetail(objSegmentDetail))
                    {
                        ((SiteMaster)this.Master).ShowMessage("Success", "Segment Detail updated successfully");
                    }
                    else
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while updating Segment Detail");
                    }
                }

                ClearPageData();
                Session["SelectedSegmentDetail"] = null;
                GetData();
                CreateTreeData();
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }