Пример #1
0
 private void CommandEdit()
 {
     try
     {
         GroupPerjawatan objGroupPerjawatan = (GroupPerjawatan)Session["SelectedGroupPerjawatan"];
         tbServiceGroup.Text            = objGroupPerjawatan.GroupPerjawatanCode;
         tbServiceDesc.Text             = objGroupPerjawatan.GroupPerjawatanDesc;
         ddlServiceStatus.SelectedIndex = -1;
         ddlServiceStatus.Items.FindByValue(new Helper().GetItemStatusEnumName(Convert.ToChar(objGroupPerjawatan.Status))).Selected = true;
     }
     catch (Exception ex)
     {
         ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
     }
 }
Пример #2
0
        private void CommandPaste(string ParentGroupPerjawatanID)
        {
            try
            {
                GroupPerjawatan cutGroupPerjawatan = (GroupPerjawatan)Session["SelectedGroupPerjawatan"];

                List <GroupPerjawatan> data   = (List <GroupPerjawatan>)Session["GroupPerjawatansData"];
                GroupPerjawatan        parent = new GroupPerjawatan()
                {
                    ParentGroupPerjawatanID = ParentGroupPerjawatanID
                };
                do
                {
                    parent = data.Where(x => x.GroupPerjawatanCode == parent.ParentGroupPerjawatanID).FirstOrDefault();
                    if (parent == null || parent.GroupPerjawatanCode == cutGroupPerjawatan.GroupPerjawatanCode)
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "You can not paste a parent under its child");
                        return;
                    }
                } while (parent.ParentGroupPerjawatanID != string.Empty);

                cutGroupPerjawatan.ParentGroupPerjawatanID = ParentGroupPerjawatanID;
                new GroupPerjawatanDAL().UpdateGroupPerjawatan(cutGroupPerjawatan);
                SelectedNodes = (List <string>)Session["SelectedNodes"];
                if (!SelectedNodes.Contains(ParentGroupPerjawatanID))
                {
                    if (((List <GroupPerjawatanTreeHelper>)Session["GroupPerjawatansTree"]).Where(x => x.GroupPerjawatanCode == ParentGroupPerjawatanID).FirstOrDefault().ChildCount > 0)
                    {
                        SelectedNodes.Add(ParentGroupPerjawatanID);
                    }
                }
                Session["SelectedNodes"] = SelectedNodes;
                //GetData();
                //CreateTreeData();
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }
Пример #3
0
 private void MakeRoot()
 {
     try
     {
         GroupPerjawatan cutGroupPerjawatan = (GroupPerjawatan)Session["SelectedGroupPerjawatan"];
         cutGroupPerjawatan.ParentGroupPerjawatanID = string.Empty;
         new GroupPerjawatanDAL().UpdateGroupPerjawatan(cutGroupPerjawatan);
         SelectedNodes = (List <string>)Session["SelectedNodes"];
         if (!SelectedNodes.Contains(cutGroupPerjawatan.GroupPerjawatanCode))
         {
             if (((List <GroupPerjawatanTreeHelper>)Session["GroupPerjawatansTree"]).Where(x => x.GroupPerjawatanCode == cutGroupPerjawatan.GroupPerjawatanCode).FirstOrDefault().ChildCount > 0)
             {
                 SelectedNodes.Add(cutGroupPerjawatan.GroupPerjawatanCode);
             }
         }
         Session["SelectedNodes"] = SelectedNodes;
         GetData();
         CreateTreeData();
     }
     catch (Exception ex)
     {
         ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
     }
 }
Пример #4
0
        public void ServicesGroupFileUpload(DataSet ds, ref List <object> ListExcluded)
        {
            object ReturnObj = new object();

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

            dt = new ReportHelper().Validate <ServiceCodeImport>(ds, "", ref lstErrors);

            if (lstErrors.Count == 0)
            {
                List <GroupPerjawatan> ServiceGroupData = (List <GroupPerjawatan>)HttpContext.Current.Session["GroupPerjawatansData"];
                List <GroupPerjawatan> UploadedData     = new ReportHelper().DataTableToList <ServiceCodeImport>(dt).Select(x => new GroupPerjawatan()
                {
                    GroupPerjawatanCode = Convert.ChangeType(x.ServiceCode, typeof(string)).ToString(),
                    GroupPerjawatanDesc = x.ServiceDesc,
                    Status = ((x.Status == "Active") ? "A" : "D"),
                    ParentGroupPerjawatanID = ((Convert.ChangeType(x.UpperLevel, typeof(string)).ToString() == "0") ? "" :
                                               Convert.ChangeType(x.UpperLevel, typeof(string)).ToString())
                }).ToList();

                if (UploadedData.Count > 0)
                {
                    foreach (GroupPerjawatan item in UploadedData)
                    {
                        GroupPerjawatan objGroupPerjawatan = new GroupPerjawatan();

                        if (ServiceGroupData.Where(x => x.GroupPerjawatanCode == item.GroupPerjawatanCode).Count() > 0)
                        {
                            ReturnObj = new
                            {
                                status  = "Error",
                                message = "Service Group **" + item.GroupPerjawatanCode + "** already exists. It`ll be excluded."
                            };
                        }
                        else
                        {
                            objGroupPerjawatan.GroupPerjawatanCode = item.GroupPerjawatanCode;
                            objGroupPerjawatan.GroupPerjawatanDesc = item.GroupPerjawatanDesc;
                            objGroupPerjawatan.Status = item.Status;
                            objGroupPerjawatan.ParentGroupPerjawatanID = item.ParentGroupPerjawatanID;
                            objGroupPerjawatan.CreatedBy         = new UsersDAL().GetValidUser(HttpContext.Current.User.Identity.Name).UserID;
                            objGroupPerjawatan.CreatedTimeStamp  = DateTime.Now;
                            objGroupPerjawatan.ModifiedBy        = new UsersDAL().GetValidUser(HttpContext.Current.User.Identity.Name).UserID;
                            objGroupPerjawatan.ModifiedTimeStamp = DateTime.Now;

                            if (new GroupPerjawatanDAL().InsertGroupPerjawatan(objGroupPerjawatan))
                            {
                                ReturnObj = new
                                {
                                    status  = "Success",
                                    message = "Service Group **" + item.GroupPerjawatanCode + "** uploaded successfully"
                                };
                            }
                            else
                            {
                                ReturnObj = new
                                {
                                    status  = "Failure",
                                    message = "An error occurred while uploading Service Group"
                                };
                            }
                        }

                        ListExcluded.Add(ReturnObj);
                    }
                }
            }
            else
            {
                ListExcluded.Add(ReturnObj = new
                {
                    status  = "Error",
                    message = lstErrors.Aggregate((a, b) => a + "<br/>" + b)
                });
            }
        }
Пример #5
0
 protected void gvGroupPerjawatans_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         List <GroupPerjawatanTreeHelper> TreeData = (List <GroupPerjawatanTreeHelper>)Session["GroupPerjawatansTree"];
         GridViewRow selectedRow     = gvGroupPerjawatans.Rows[Convert.ToInt32(e.CommandArgument)];
         string      GroupPerjawatan = gvGroupPerjawatans.DataKeys[selectedRow.RowIndex]["GroupPerjawatanCode"].ToString();
         if (e.CommandName == "Expand")
         {
             SelectedNodes = (List <string>)Session["SelectedNodes"];
             if (!SelectedNodes.Contains(GroupPerjawatan))
             {
                 if (TreeData.Where(x => x.GroupPerjawatanCode == GroupPerjawatan).FirstOrDefault().ChildCount > 0)
                 {
                     SelectedNodes.Add(GroupPerjawatan);
                 }
             }
             else
             {
                 SelectedNodes.Remove(GroupPerjawatan);
             }
             CreateTreeData();
         }
         else if (e.CommandName == "AddItem")
         {
             Session["PageMode"]    = Helper.PageMode.New;
             EditForm.Visible       = true;
             tbServiceGroup.Enabled = true;
         }
         else if (e.CommandName == "AddChild")
         {
             ClearPageData();
             ChangeSeletedNodeStyle(selectedRow);
             AssignSelectedNode(GroupPerjawatan);
             Session["PageMode"]    = Helper.PageMode.New;
             EditForm.Visible       = true;
             tbServiceGroup.Enabled = true;
         }
         else if (e.CommandName == "MakeRoot")
         {
             ChangeSeletedNodeStyle(selectedRow);
             AssignSelectedNode(GroupPerjawatan);
             MakeRoot();
             ClearPageData();
         }
         else if (e.CommandName == "CmdEdit")
         {
             ChangeSeletedNodeStyle(selectedRow);
             AssignSelectedNode(GroupPerjawatan);
             CommandEdit();
             Session["PageMode"]    = Helper.PageMode.Edit;
             EditForm.Visible       = true;
             tbServiceGroup.Enabled = false;
         }
         else if (e.CommandName == "CmdDelete")
         {
             AssignSelectedNode(GroupPerjawatan);
             GroupPerjawatan objGroupPerjawatan = (GroupPerjawatan)Session["SelectedGroupPerjawatan"];
             objGroupPerjawatan.Status            = "D";
             objGroupPerjawatan.ModifiedBy        = LoggedInUser.UserID;
             objGroupPerjawatan.ModifiedTimeStamp = DateTime.Now;
             if (new GroupPerjawatanDAL().UpdateGroupPerjawatan(objGroupPerjawatan))
             {
                 ((SiteMaster)this.Master).ShowMessage("Success", "Service Group updated successfully");
             }
             else
             {
                 ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while updating Service Group");
             }
             ClearPageData();
             Session["SelectedGroupPerjawatan"] = null;
             GetData();
             CreateTreeData();
         }
         else if (e.CommandName == "CmdCut")
         {
             ChangeSeletedNodeStyle(selectedRow);
             AssignSelectedNode(GroupPerjawatan);
         }
         else if (e.CommandName == "CmdPaste")
         {
             CommandPaste(GroupPerjawatan);
             GetData();
             CreateTreeData();
         }
     }
     catch (Exception ex)
     {
         ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
     }
 }
Пример #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                GroupPerjawatan objGroupPerjawatan = new GroupPerjawatan();
                objGroupPerjawatan.GroupPerjawatanCode = tbServiceGroup.Text.Trim();
                objGroupPerjawatan.GroupPerjawatanDesc = tbServiceDesc.Text.Trim();
                objGroupPerjawatan.Status = new Helper().GetItemStatusEnumValueByName(ddlServiceStatus.SelectedValue);
                if ((GroupPerjawatan)Session["SelectedGroupPerjawatan"] == null)
                {
                    objGroupPerjawatan.ParentGroupPerjawatanID = string.Empty;
                }
                else
                {
                    objGroupPerjawatan.ParentGroupPerjawatanID = ((GroupPerjawatan)Session["SelectedGroupPerjawatan"]).GroupPerjawatanCode;
                }

                if (((Helper.PageMode)Session["PageMode"]) == Helper.PageMode.New)
                {
                    if (new GroupPerjawatanDAL().GetGroupPerjawatans().Where(x => x.GroupPerjawatanCode.ToUpper().Trim() == tbServiceGroup.Text.ToUpper().Trim()).Count() > 0)
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "ServiceCode already exists");
                        return;
                    }
                    objGroupPerjawatan.CreatedBy         = LoggedInUser.UserID;
                    objGroupPerjawatan.CreatedTimeStamp  = DateTime.Now;
                    objGroupPerjawatan.ModifiedBy        = LoggedInUser.UserID;
                    objGroupPerjawatan.ModifiedTimeStamp = DateTime.Now;

                    if (new GroupPerjawatanDAL().InsertGroupPerjawatan(objGroupPerjawatan))
                    {
                        ((SiteMaster)this.Master).ShowMessage("Success", "Service Group saved successfully");
                    }
                    else
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while saving Service Group");
                    }
                }
                else
                {
                    objGroupPerjawatan.ModifiedBy        = LoggedInUser.UserID;
                    objGroupPerjawatan.ModifiedTimeStamp = DateTime.Now;

                    objGroupPerjawatan.GroupPerjawatanCode     = ((GroupPerjawatan)Session["SelectedGroupPerjawatan"]).GroupPerjawatanCode;
                    objGroupPerjawatan.ParentGroupPerjawatanID = ((GroupPerjawatan)Session["SelectedGroupPerjawatan"]).ParentGroupPerjawatanID;
                    if (new GroupPerjawatanDAL().UpdateGroupPerjawatan(objGroupPerjawatan))
                    {
                        ((SiteMaster)this.Master).ShowMessage("Success", "Service Group updated successfully");
                    }
                    else
                    {
                        ((SiteMaster)this.Master).ShowMessage("Failure", "An error occurred while updating Service Group");
                    }
                }

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