public void LoadContacts() { var _page = new PageBase(); var doc = _page.DocNumber; var org = _page.OrgCode; var ds = Item.GetItemContactList(doc, org); if (ds != null && ds.Tables[0].Rows.Count > 0) { //if (tblContacts.Rows.Count > 0) //{ // tblContacts.Rows.Clear(); //} //foreach (DataRow dr in tblContacts.Rows) //{ //} foreach (DataRow dr in ds.Tables[0].Rows) { var td1 = new HtmlTableCell(); td1.AddStyle("width:22px;"); if (Enabled) { td1.InnerHtml = "<img id='btnDeleteContact' src='../images/btn_contact_delete.gif' title='remove contact' class='icDelete' onclick='javascript:return remove_contact(this);' alt='Remove Contact' />"; } if (btnAddContact.Disabled == false) { td1.InnerHtml = "<img id='btnDeleteContact' src='../images/btn_contact_delete.gif' title='remove contact' class='icDelete' onclick='javascript:return remove_contact(this);' alt='Remove Contact' />"; } var td2 = new HtmlTableCell(); td2.AddBldBlueText(); td2.InnerText = (string)dr["RoleDescription"]; var td3 = new HtmlTableCell(); td3.AddRegText(); td3.InnerText = (string)dr["FullName"]; var td4 = new HtmlTableCell(); if (dr["Phone"] != DBNull.Value) { td4.InnerHtml = "<label class='regText' >" + (string)dr["Phone"] + "</label>"; } var tr = new HtmlTableRow(); tr.Cells.Add(td1); tr.Cells.Add(td2); tr.Cells.Add(td3); tr.Cells.Add(td4); tblContacts.Rows.Add(tr); } } }
private void DrawTable() { decimal total_amount = 0; var read_only = true; if (User.IsInRole(((int)UserRoles.urFSBDAnalystFundsCoordinator).ToString()) && Organization != "") { read_only = false; } else if (!User.IsInRole(((int)UserRoles.urFSBDAnalystFundsCoordinator).ToString())) { var user_role = Users.UserAuthorizedForFSReports(CurrentUserID, BusinessLineCode, Organization); if (user_role <= 0) { throw new Exception("You are not authorized to visit this page."); } else if (user_role == (int)UserRoles.urFSOrgAdminWR && Organization != "") { read_only = false; } } var _add_awards = (AdjustmentsAdditional == "award") ? true : false; var _add_training = (AdjustmentsAdditional == "training") ? true : false; var _add_travel = (AdjustmentsAdditional == "travel") ? true : false; //get the data: var ds = FSDataServices.GetUserEntryData(DataEntryType, FiscalYear, BookMonth, Organization, BusinessLineCode, ReportGroupCode, _add_awards, _add_training, _add_travel, false); HtmlTableRow tr = null; HtmlTableCell td = null; int entry_id; string doc_number; decimal amount; string explanation; string entry_month; //remove first column if there is no permission for edit or delete: if (read_only) { tblData.Rows[0].Cells[0].InnerText = "BookMonth"; } //tblData.Rows[0].Cells[0].AddDisplayNone(); var iRowCount = 0; ds.Tables[0].Columns["Amount"].ColumnName = "$ Amount"; foreach (DataRow dr in ds.Tables[0].Rows) { entry_id = (int)dr["EntryID"]; entry_month = String.Format("{0:MMMM}", DateTime.Parse(dr["BookMonth"].ToString() + "/" + dr["FiscalYear"].ToString())); doc_number = (string)Utility.GetNotNullValue(dr["DocNumber"], "String"); amount = (decimal)dr["$ Amount"]; total_amount += amount; explanation = (string)Utility.GetNotNullValue(dr["Explanation"], "String"); tr = new HtmlTableRow(); tr.AddCssClass((iRowCount++) % 2 > 0 ? "tRowAlt" : "tRow"); if (entry_id >= 0 && !read_only && dr["BookMonth"].ToString() == BookMonth) { td = new HtmlTableCell(); var btnEdit = new HtmlInputImage(); btnEdit.ID = "edit_ctrl_" + entry_id.ToString(); btnEdit.Src = "../images/note.gif"; btnEdit.Alt = "Edit record"; btnEdit.AddOnClick("return edit_row(this," + entry_id.ToString() + "," + DataEntryType.ToString() + ");"); td.Controls.Add(btnEdit); tr.Cells.Add(td); td = new HtmlTableCell(); var btnDelete = new HtmlInputImage(); btnDelete.ID = "delete_ctrl_" + entry_id.ToString(); btnDelete.Src = "../images/btn_contact_delete.gif"; btnDelete.Alt = "Delete record"; btnDelete.AddOnClick("return delete_row(this," + entry_id.ToString() + "," + DataEntryType.ToString() + ");"); td.Controls.Add(btnDelete); tr.Cells.Add(td); } else { td = new HtmlTableCell(); td.ColSpan = 2; td.InnerText = entry_month; tr.Cells.Add(td); } td = new HtmlTableCell(); if (entry_id < 0) { td.InnerHtml = "<font color='green'>Show Details</font>"; td.AddOnClick("Expand(this)"); td.AddTitle("Expand"); td.Style.Add("cursor", "pointer"); } else { td.InnerHtml = doc_number != "" ? doc_number : " "; } tr.Cells.Add(td); td = new HtmlTableCell(); td.InnerText = amount == 0 ? "0" : String.Format("{0:0,0}", Convert.ToInt64(amount)); td.Align = "right"; tr.Cells.Add(td); td = new HtmlTableCell(); td.InnerHtml = explanation != "" ? explanation : " "; tr.Cells.Add(td); tblData.Rows.Add(tr); if (entry_id < 0) //expanded table { tr = new HtmlTableRow(); tr.Style.Add("display", "none"); td = new HtmlTableCell(); tr.Cells.Add(td); td = new HtmlTableCell(); td.ColSpan = 4; var mg = new MultiGrid(); mg = (MultiGrid)Page.LoadControl("..\\Controls\\MultiGrid.ascx"); td.Controls.Add(mg); tr.Cells.Add(td); tblData.Rows.Add(tr); var dtO = FundStatus.GetUserEntryDataList(DataEntryType, FiscalYear, BookMonth, Organization, BusinessLineCode, ReportGroupCode, entry_id).Tables[0]; var dt = dtO.Clone(); dt.Columns["Amount"].DataType = typeof(string); foreach (DataRow r in dtO.Rows) { dt.ImportRow(r); } dt.Columns["Amount"].ColumnName = "$ Amount"; foreach (DataRow r in dt.Rows) { r["Month"] = Month[Convert.ToInt32(r["Month"]) - 1]; r["$ Amount"] = String.Format("{0:0,0}", Convert.ToInt64(Convert.ToDecimal(r["$ Amount"]))); if (r["$ Amount"].ToString() == "00") { r["$ Amount"] = "0"; } } mg.Table = dt; mg.TblCSSClass = "eTbl"; mg.TblBorderClass = "eBorder"; mg.HeaderCSSClass = "reportHeaderGreen"; mg.ItemCSSClass = "eRow"; mg.Height = Unit.Pixel(dt.Rows.Count * 18 + 19); //make it not scrollable by setting full height } } //add row for insert record - if applicable if (!read_only) { HtmlInputText txt; tr = new HtmlTableRow(); tr.AddCssClass((iRowCount++) % 2 > 0 ? "tRowAlt" : "tRow"); td = new HtmlTableCell(); var btnCancel = new HtmlInputImage(); btnCancel.ID = "cancel_ctrl_new"; btnCancel.Src = "../images/back.gif"; btnCancel.Alt = "Cancel changes"; btnCancel.AddWidth(12); btnCancel.AddHeight(12); btnCancel.AddOnClick("return cancel_edit(this);"); td.Controls.Add(btnCancel); tr.Cells.Add(td); td = new HtmlTableCell(); var btnEdit = new HtmlInputImage(); btnEdit.ID = "save_ctrl_new"; btnEdit.Src = "../images/save.gif"; btnEdit.Alt = "Save new record"; btnEdit.AddWidth(12); btnEdit.AddHeight(12); btnEdit.AddOnClick("return save_row(this,0," + DataEntryType.ToString() + ");"); td.Controls.Add(btnEdit); tr.Cells.Add(td); td = new HtmlTableCell(); td.AddStyle("padding-left:5px;padding-right:5px"); txt = new HtmlInputText(); txt.AddStyle("width:100%;height:15px;text-align:center;"); td.Controls.Add(txt); tr.Cells.Add(td); td = new HtmlTableCell(); td.AddStyle("padding-left:5px;padding-right:5px"); txt = new HtmlInputText(); txt.AddStyle("width:100%;height:15px;text-align:center;"); txt.AddOnMouseOut("extractNumber(this,0,true,9999999999);"); txt.AddOnKeyUp("extractNumber(this,0,true,9999999999);"); txt.AddKeyPressBlockNonNumbers(); td.Controls.Add(txt); tr.Cells.Add(td); td = new HtmlTableCell(); td.AddStyle("padding-left:5px;padding-right:5px"); txt = new HtmlInputText(); txt.AddStyle("width:100%;height:15px;text-align:center;"); td.Controls.Add(txt); tr.Cells.Add(td); tblData.Rows.Add(tr); } lblAmount.Text = total_amount == 0 ? "0" : String.Format("{0:$0,0}", Convert.ToInt64(total_amount)); }