private void CreateTreeData() { try { List <string> SelectedNodes = (List <string>)Session["SelectedNodes"]; List <AccountCode> AccountCodesData = (List <AccountCode>)Session["AccountCodesData"]; List <AccountCodeTreeHelper> TreeData = new List <AccountCodeTreeHelper>(); if (AccountCodesData.Count > 0) { TreeData = AccountCodesData.Where(x => x.ParentAccountCode == string.Empty && x.Status == "A").OrderBy(x => x.AccountCode1).Select(x => new AccountCodeTreeHelper() { AccountCode = x.AccountCode1, AccountDesc = x.AccountDesc, Keterangan = x.Keterangan, Pengiraan = x.Pengiraan, ParentAccountCode = x.ParentAccountCode, Status = x.Status, Level = 0, ChildCount = AccountCodesData.Where(y => y.ParentAccountCode == x.AccountCode1).Count() }).ToList(); if (SelectedNodes == null || SelectedNodes.Count == 0) { Session["SelectedNodes"] = new List <string>(); SelectedNodes = new List <string>(); } else { for (int i = 0; i < TreeData.Count; i++) { if (SelectedNodes.Contains(TreeData[i].AccountCode)) { foreach (AccountCode sd in AccountCodesData.Where(x => x.ParentAccountCode == TreeData[i].AccountCode && x.Status == "A").OrderByDescending(x => x.AccountCode1)) { AccountCodeTreeHelper objSH = new AccountCodeTreeHelper() { AccountCode = sd.AccountCode1, AccountDesc = sd.AccountDesc, Keterangan = sd.Keterangan, Pengiraan = sd.Pengiraan, ParentAccountCode = sd.ParentAccountCode, Status = sd.Status, Level = TreeData[i].Level + 1, ChildCount = AccountCodesData.Where(y => y.ParentAccountCode == sd.AccountCode1).Count() }; TreeData.Insert(i + 1, objSH); } } } } } Session["AccountCodesTree"] = TreeData; } catch (Exception ex) { ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true); } }
private List <AccountCodeTreeHelper> CreateExportData() { List <AccountCodeTreeHelper> TreeData = new List <AccountCodeTreeHelper>(); try { List <AccountCode> data = (List <AccountCode>)Session["AccountCodesData"]; if (data.Count > 0) { TreeData = data.Where(x => x.ParentAccountCode == string.Empty).OrderBy(x => x.AccountCode1).Select(x => new AccountCodeTreeHelper() { AccountCode = x.AccountCode1, AccountDesc = x.AccountDesc, Keterangan = x.Keterangan, Pengiraan = x.Pengiraan, ParentAccountCode = x.ParentAccountCode, Status = x.Status, Level = 0, ChildCount = data.Where(y => y.ParentAccountCode == x.AccountCode1).Count() }).ToList(); for (int i = 0; i < TreeData.Count; i++) { foreach (AccountCode sd in data.Where(x => x.ParentAccountCode == TreeData[i].AccountCode).OrderByDescending(x => x.AccountCode1)) { AccountCodeTreeHelper objSH = new AccountCodeTreeHelper() { AccountCode = sd.AccountCode1, AccountDesc = sd.AccountDesc, Keterangan = sd.Keterangan, Pengiraan = sd.Pengiraan, ParentAccountCode = sd.ParentAccountCode, Status = sd.Status, Level = TreeData[i].Level + 1, ChildCount = data.Where(y => y.ParentAccountCode == sd.AccountCode1).Count() }; TreeData.Insert(i + 1, objSH); } } } } catch (Exception ex) { ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true); } return(TreeData); }
//protected void btnCancel_Click(object sender, EventArgs e) //{ // ClearPageData(); // Session["SelectedAccountCode"] = null; //} protected void gvAccountCodes_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { AccountCodeTreeHelper rowItem = (AccountCodeTreeHelper)e.Row.DataItem; //((Label)e.Row.FindControl("lblIndent")).Width = Unit.Pixel(rowItem.Level * 30); //((Label)e.Row.FindControl("lblDetailCode")).Text = rowItem.DetailCode; int width = rowItem.Level * 30; string strHTML = string.Empty; if (rowItem.ChildCount > 0) { if (SelectedNodes.Contains(rowItem.AccountCode)) { strHTML = "<label style=\"width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i class=\"ace-icon fa fa-minus-square pull-right\"></i></label> "; } else { strHTML = "<label style=\"width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i class=\"ace-icon fa fa-plus-square pull-right\"></i></label> "; } } else { strHTML = "<label style=\"width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i></i></label> "; } LinkButton btnExpand = ((LinkButton)e.Row.FindControl("btnExpand")); btnExpand.Text = "<div>" + strHTML + rowItem.AccountCode + "</div>"; if (rowItem.ParentAccountCode != string.Empty) { ((LinkButton)e.Row.FindControl("lbAddItem")).Visible = false; } if (rowItem.ParentAccountCode == string.Empty) { ((LinkButton)e.Row.FindControl("lbMakeRoot")).Visible = false; } if (rowItem.AccountCode == string.Empty) { ((LinkButton)e.Row.FindControl("btnExpand")).Visible = false; ((LinkButton)e.Row.FindControl("lbEit")).Visible = false; ((LinkButton)e.Row.FindControl("lbDelete")).Visible = false; ((LinkButton)e.Row.FindControl("lbCut")).Visible = false; ((LinkButton)e.Row.FindControl("lbPaste")).Visible = false; ((LinkButton)e.Row.FindControl("lbMakeRoot")).Visible = false; ((LinkButton)e.Row.FindControl("lbAddChild")).Visible = false; } if (Session["SelectedAccountCode"] != null && ((AccountCode)Session["SelectedAccountCode"]).AccountCode1 == rowItem.AccountCode) { e.Row.Style["background-color"] = "skyblue"; } var span = ((HtmlGenericControl)e.Row.Cells[2].FindControl("CustomStatus")); if (rowItem.Status == "A") { //span.Attributes["class"] = "label label-success"; //span.InnerHtml = "<i class=\"fa fa-flag green bigger-150 tooltip-success\" data-rel=\"tooltip\" data-placement=\"right\" title=\"Active\"></i>"; span.InnerHtml = "<span class=\"label label-sm label-success arrowed-in arrowed-in-right tooltip-success\" " + "data-rel=\"tooltip\" data-placement=\"right\" title=\"Active Status. All operation has been enabled.\">Active</span>"; } else if (rowItem.Status == "D") { //span.InnerHtml = "<i class=\"fa fa-flag red bigger-150 tooltip-error\" data-rel=\"tooltip\" data-placement=\"right\" title=\"Inactive\"></i>"; span.InnerHtml = "<span class=\"label label-sm label-danger arrowed-in arrowed-in-right tooltip-error\" " + "data-rel=\"tooltip\" data-placement=\"right\" title=\"Inactive Status. All operation has been disabled.\">Inactive</span>"; } } } catch (Exception ex) { ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true); } }
protected void gvAccountCodes_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { List <string> SelectedNodes = (List <string>)Session["SelectedNodes"]; List <BudgetMenguru> BudgetData = (List <BudgetMenguru>)Session["BudgetData"]; List <AccountCodeTreeHelper> TreeData = (List <AccountCodeTreeHelper>)Session["AccountCodesTree"]; List <AccountCode> AccountCodesData = (List <AccountCode>)Session["AccountCodesData"]; List <PeriodMenguru> PeriodData = (List <PeriodMenguru>)Session["PeriodData"]; AccountCodeTreeHelper rowItem = (AccountCodeTreeHelper)e.Row.DataItem; /*Start Account Code logics*/ int width = rowItem.Level * (new Helper().IndentPixels); string strHTML = string.Empty; if (rowItem.ChildCount > 0) { if (SelectedNodes.Contains(rowItem.AccountCode)) { strHTML = "<label style=\"display: inline-block;width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i class=\"ace-icon fa fa-minus-square pull-right\"></i></label> "; } else { strHTML = "<label style=\"display: inline-block;width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i class=\"ace-icon fa fa-plus-square pull-right\"></i></label> "; } } else { strHTML = "<label style=\"display: inline-block;width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i></i></label> "; } LinkButton btnExpand = ((LinkButton)e.Row.Cells[0].FindControl("btnExpand")); //btnExpand.Text = "<div style=\"max-width:200px;overflow:hidden;white-space:nowrap;\">" + strHTML + Session["PrefixAcountCode"].ToString() + rowItem.AccountCode + "</div>"; btnExpand.Text = "<div style=\"max-width:200px;overflow:hidden;white-space:nowrap;\">" + strHTML + rowItem.AccountCode + "</div>"; btnExpand.ToolTip = rowItem.AccountDesc; //if (Session["SelectedAccountCode"] != null && ((AccountCode)Session["SelectedAccountCode"]).AccountCode1 == rowItem.AccountCode) //{ // e.Row.Style["background-color"] = "skyblue"; //} //if (SelectedNodes.Contains(rowItem.AccountCode)) //{ // e.Row.Style["background-color"] = "skyblue"; //} /*End Account Code logics*/ /*Start Buget logics*/ int index = 2; if (chkKeterangan.Checked) { index++; } if (chkPengiraan.Checked) { index++; } bool IsBudgetEditable = Convert.ToBoolean(Session["CanEdit"]); for (int c = index; c < gvAccountCodes.Columns.Count; c++) { //int PeriodMenguruID = Convert.ToInt32(((Label)e.Row.Cells[c].FindControl("lbl_PeriodMenguruID")).Text); int PeriodMenguruID = Convert.ToInt32(((Label)e.Row.Cells[c].Controls[0]).Text); PeriodMenguru pm = PeriodData.Where(x => x.PeriodMengurusID == PeriodMenguruID).FirstOrDefault(); BudgetMenguru ObjBudgetMenguru = BudgetData.Where(x => x.AccountCode == rowItem.AccountCode && x.PeriodMengurusID == PeriodMenguruID).FirstOrDefault(); Label lbl = ((Label)e.Row.Cells[c].FindControl("lbl_" + PeriodMenguruID)); LinkButton btnSaved = ((LinkButton)e.Row.Cells[c].FindControl("btnSaved_" + PeriodMenguruID)); LinkButton btnPrepared = ((LinkButton)e.Row.Cells[c].FindControl("btnPrepared_" + PeriodMenguruID)); LinkButton btnReviewed = ((LinkButton)e.Row.Cells[c].FindControl("btnReviewed_" + PeriodMenguruID)); LinkButton btnApproved = ((LinkButton)e.Row.Cells[c].FindControl("btnApproved_" + PeriodMenguruID)); LinkButton btnRevRej = ((LinkButton)e.Row.Cells[c].FindControl("btnRevRej_" + PeriodMenguruID)); LinkButton btnAprRej = ((LinkButton)e.Row.Cells[c].FindControl("btnAprRej_" + PeriodMenguruID)); lbl.Visible = true; btnSaved.Visible = false; btnPrepared.Visible = false; btnReviewed.Visible = false; btnApproved.Visible = false; btnRevRej.Visible = false; btnAprRej.Visible = false; e.Row.Cells[c].BackColor = ((ObjBudgetMenguru != null) ? new Helper().GetColorByStatusValue('A') : new System.Drawing.Color()); if (rowItem.ChildCount == 0) { lbl.Text = (ObjBudgetMenguru != null) ? ObjBudgetMenguru.Amount.ToString() : string.Empty; } else { decimal amount = 0; List <string> ChildIDs = new List <string>() { rowItem.AccountCode }; List <string> RefChildIDs = new List <string>(); while (ChildIDs.Count > 0) { RefChildIDs.Clear(); foreach (AccountCode t in AccountCodesData.Where(x => ChildIDs.Contains(x.AccountCode1))) { amount = amount + BudgetData.Where(x => x.AccountCode == t.AccountCode1 && x.PeriodMengurusID == PeriodMenguruID).Select(x => x.Amount).Sum(); foreach (string s in AccountCodesData.Where(x => x.ParentAccountCode == t.AccountCode1).Select(x => x.AccountCode1).ToList()) { RefChildIDs.Add(s); } } ChildIDs.Clear(); foreach (string s in RefChildIDs) { ChildIDs.Add(s); } } lbl.Text = (amount != 0) ? amount.ToString("F") : string.Empty; } } /*End Buget logics*/ } } catch (Exception ex) { ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true); } }