Public Sub getparentfolders(ByVal parentid As String, ByVal name As String, ByVal rootnode As RadTreeNode)
DBConn =
New SqlConnection(ConfigurationManager.ConnectionStrings("db").ToString)
Dim roottable As New DataTable
Dim rootrow As DataRow
roottable = FolderAPI.GetAllFoldersByParent(parentid, DBConn)
Dim subtable As New DataTable
For Each rootrow In roottable.Rows
Dim ParentNode As New RadTreeNode
ParentNode.Text = rootrow(1).ToString
ParentNode.Value = rootrow(0).ToString
'Do I have sub folders
subtable = FolderAPI.GetAllFoldersByParent(rootrow(0).ToString, DBConn)
If subtable.Rows.Count = 0 Then
rootnode.Nodes.Add(ParentNode)
Else
name = rootrow(1).ToString
getchildfolder(rootrow(0).ToString, name, ParentNode, rootnode, childnode)
End If
Next
FolderList.Nodes.Add(rootnode)
End Sub
Public Sub getchildfolder(ByVal parentid As String, ByVal name As String, ByVal ParentNode As RadTreeNode, ByVal rootnode As RadTreeNode, ByVal Childnode As RadTreeNode)
If Childnode.Text = "" Then Childnode = ParentNode
DBConn =
New SqlConnection(ConfigurationManager.ConnectionStrings("db").ToString)
Dim roottable As New DataTable
Dim rootrow As DataRow
roottable = FolderAPI.GetAllFoldersByParent(parentid, DBConn)
If roottable.Rows.Count < 1 Then
Try
rootnode.Nodes.Add(ParentNode)
Catch ex As Exception
Dim parentnode2 As New RadTreeNode
parentnode2.Text = name
parentnode2.Value = parentid
Dim rootnode2 As New RadTreeNode
rootnode2.Text =
"Home"
rootnode2.Value = 0
rootnode = rootnode2
rootnode.Nodes.Add(parentnode2)
End Try
End If
Dim newchild As New RadTreeNode
For Each rootrow In roottable.Rows
'Do I have more folders
name = rootrow(1).ToString
newchild.Text = name
newchild.Value = parentid
Childnode.Nodes.Add(newchild)
'getparentfolders(parentid, name, ParentNode)
getchildfolder(rootrow(0).ToString, name, ParentNode, rootnode, newchild)
Next
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rootnode As New RadTreeNode
rootnode.Value = -1
rootnode.Text =
"Root"
getparentfolders(
"0", "Root", rootnode)
|
| <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Notes.ascx.cs" Inherits="Notes" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <html> |
| <head> |
| <style type="text/css"> |
| body |
| { |
| background-color: #d3d3d3; |
| } |
| img |
| { |
| border: none; |
| } |
| .notesblock |
| { |
| width: 99%; |
| margin: 0 0 0 0; |
| } |
| .noteslist |
| { |
| color: #8a8c8f; |
| list-style-type: none; |
| padding: 0px 1px; |
| font-family: "Lucida Grande" , "Segoe UI" , "Bitstream Vera Sans" , Tahoma, Verdana, Arial,sans-serif; |
| font-size: 10px; |
| line-height: 160%; |
| } |
| #saveButton |
| { |
| position: absolute; |
| top: 280px; |
| right: 75px; |
| } |
| #cancelButton |
| { |
| position: absolute; |
| top: 280px; |
| right: 12px; |
| } |
| #expandButton |
| { |
| position: absolute; |
| top: 20px; |
| right: 5px; |
| } |
| </style> |
| <script type="text/javascript"> |
| function clearText(field) { |
| var selectString = "Click to Enter New Note"; |
| if (field.defaultValue == selectString) field.value = ''; |
| // if (field.defaultValue == selectString) field.value = ''; |
| // else if (field.value == '') fieldfield.value = field.defaultValue; |
| } |
| function resizeTB() { |
| var tb = $find("<%= txtUserNote.ClientID %>"); |
| // tb._originalTextBoxCssText = "width:99%;height:35px;"; |
| // tb.updateCssClass(); |
| return false; |
| } |
| function ButtonClick(sender, e) { |
| var radTextBox = sender; |
| radTextBox.raisePostBackEvent(); |
| } |
| </script> |
| </head> |
| <body bgcolor="#F4F4F4" runat="server" id="MainBody"> |
| <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="100%" Width="100%"> |
| <asp:Literal ID="notesHeader" runat="server"> |
| </asp:Literal> |
| <telerik:RadTextBox ID="txtUserNote" runat="server" TextMode="MultiLine" Width="99%" |
| Height="15px" Visible="False" EmptyMessage="Click to Enter New Note" Font-Size="10px" |
| AutoPostBack="true"> |
| </telerik:RadTextBox> |
| <div id="expandButton"> |
| <asp:ImageButton runat="server" ID="expandTbButton" ImageUrl="images/expand.gif" |
| OnClientClick="return resizeTB()" /> |
| </div> |
| <div id="saveButton"> |
| <asp:Button ID="SaveButton" Height="20px" Font-Size="10px" runat="server" Text="Save" |
| Visible="False" OnClick="SaveButton_Click" /> |
| </div> |
| <div id="cancelButton"> |
| <asp:Button ID="CancelButton" Height="20px" Font-Size="10px" runat="server" Text="Cancel" |
| OnClick="CancelButton_Click" Visible="False" /> |
| </div> |
| </telerik:RadAjaxPanel> |
| <div id="allnotes"> |
| <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" Width="562px" Style="background-color: #d3d3d3;"> |
| <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Style="background-color: #d3d3d3;" |
| EnableEmbeddedSkins="false" Skin="Custom" Height="200px" Width="562px" ExpandMode="FullExpandedItem"> |
| </telerik:RadPanelBar> |
| </telerik:RadAjaxPanel> |
| </div> |
| </body> |
| </html> |
| public partial class Notes : System.Web.UI.UserControl, IPostBackDataHandler |
| { |
| #region variables |
| private string noteText = string.Empty; |
| private string userNote = string.Empty; |
| private string sessionNoteKey = "4"; |
| private string modeKey = "5"; |
| private string tempNoteTextKey = "6"; |
| public static string invoiceNotesObjectKey = "7"; |
| #endregion |
| #region Page event handlers |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| Notes notes = (Notes)Session[invoiceNotesObjectKey]; |
| LoadNoteHistory(notes); |
| if (notes == null) |
| { |
| notes = new Notes(); |
| } |
| txtUserNote.Visible = true; |
| CancelButton.Visible = true; |
| SaveButton.Visible = true; |
| } |
| #endregion |
| #region enumerations |
| private enum Mode |
| { |
| Delete = 0, |
| Edit, |
| New |
| } |
| #endregion |
| #region properties |
| public string NoteText |
| { |
| get { return noteText; } |
| set { noteText = value; } |
| } |
| public string UserNote |
| { |
| get { return userNote; } |
| set { userNote = value; } |
| } |
| #endregion |
| #region public methods |
| public void AddNote(Invoice invoice) |
| { |
| Notes notes = ((Notes)Session[this.sessionNoteKey]); |
| Note note = notes[notes.Count - 1]; |
| note.DateTime = System.DateTime.Now; |
| note.DocId = invoice.ID; |
| note.Username = invoice.Username; |
| note.Save = true; |
| invoice.Notes.Add(note); |
| } |
| public bool LoadNoteHistory(Notes notes) |
| { |
| StringBuilder stringBuilder; |
| int counter = 1; |
| Session[this.sessionNoteKey] = notes; |
| XmlDocument xmlDoc = new XmlDocument(); |
| XmlElement notesBlock = xmlDoc.CreateElement("div"); |
| notesBlock.SetAttribute("class", "notesblock"); |
| xmlDoc.AppendChild(notesBlock); |
| stringBuilder = new StringBuilder("<div class=\"notesblock\">"); |
| stringBuilder.Append("<ol class=\"noteslist\">"); |
| stringBuilder.Append("<li>"); |
| notesHeader.Text = stringBuilder.ToString(); |
| xmlDoc = new XmlDocument(); |
| notesBlock = xmlDoc.CreateElement("div"); |
| notesBlock.SetAttribute("class", "notesblock"); |
| xmlDoc.AppendChild(notesBlock); |
| RadPanelBar1.Items.Clear(); |
| for (int i = 0; i < notes.Count; i++) |
| { |
| String userName = notes[i].Username; |
| String pendingStatus = " - Pending "; |
| String dateTime = notes[i].DateTime.ToShortDateString(); |
| String noteText = notes[i].Text.ToString(); |
| String newNote; |
| if (notes[i].Save == true) |
| { |
| Session[tempNoteTextKey] = txtUserNote.Text; |
| newNote = userName + pendingStatus + dateTime + " " + noteText; |
| txtUserNote.Text = notes[i].Text; |
| } |
| else |
| { |
| CreateRPI(userName, dateTime, noteText); |
| } |
| counter++; |
| } |
| if (this.noteText.Length != 0) |
| { |
| return true; |
| } |
| return false; |
| } |
| #endregion |
| #region protected methods |
| protected void CancelButton_Click(object sender, EventArgs e) |
| { |
| txtUserNote.Text = string.Empty; |
| txtUserNote.Visible = false; |
| CancelButton.Visible = false; |
| SaveButton.Visible = false; |
| } |
| protected void SaveButton_Click(object sender, EventArgs e) |
| { |
| Note note; |
| CIS.Common.Business.Objects.InvoiceRouter.Notes notes; |
| bool isThereANewNote; |
| if (txtUserNote.Text.Length != 0) |
| { |
| notes = (Notes)Session[this.sessionNoteKey]; |
| isThereANewNote = false; |
| foreach(Note n in notes) { |
| if (n.Save) |
| { |
| isThereANewNote = true; |
| break; |
| } |
| } |
| if (!isThereANewNote) |
| { |
| note = new Note(); |
| note.DateTime = System.DateTime.Now; |
| if (Session[tempNoteTextKey] == null) |
| { |
| note.Text = txtUserNote.Text; |
| } |
| else |
| { |
| note.Text = Session[tempNoteTextKey].ToString(); |
| } |
| txtUserNote.Text = note.Text; |
| note.Username = (Session[Key]).UserName.ToUpper(); |
| note.Save = true; |
| notes.Add(note); |
| } |
| else |
| { |
| note = notes[notes.Count - 1]; |
| note.DateTime = System.DateTime.Now; |
| if (Session[tempNoteTextKey] == null) |
| { |
| note.Text = txtUserNote.Text; |
| } |
| else |
| { |
| note.Text = Session[tempNoteTextKey].ToString(); |
| } |
| txtUserNote.Text = note.Text; |
| note.Save = true; |
| } |
| LoadNoteHistory(notes); |
| } |
| txtUserNote.Visible = true; |
| CancelButton.Visible = true; |
| SaveButton.Visible = true; |
| } |
| protected void txtUserNote_TextChanged(object sender, EventArgs e) |
| { |
| this.userNote = txtUserNote.Text; |
| } |
| #endregion |
| #region event handlers |
| #endregion |
| #region IPostBackDataHandler Members |
| public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection) |
| { |
| return true; |
| } |
| public void RaisePostDataChangedEvent() |
| { |
| //Not Implemented |
| } |
| #endregion |
| #region RadPanelItem Creation |
| RadPanelItem CreateRPI(String panelItemName1, String panelItemName2, String panelItems1) |
| { |
| RadPanelItem rpi = new RadPanelItem(); |
| rpi.Text = panelItemName1 + " " + panelItemName2; |
| rpi.Font.Size = 8; |
| RadPanelItem rpItem = new RadPanelItem(); |
| rpItem.Text = panelItems1; |
| rpItem.Font.Size = 8; |
| rpi.Items.Add(rpItem); |
| RadPanelBar1.Items.Add(rpi); |
| return rpi; |
| } |
| RadPanelItem CreateNewNote(String panelItemName1, String pendingItem, String panelItemName2, String panelItems1) |
| { |
| RadPanelItem rpi = new RadPanelItem(); |
| rpi.Text = panelItemName1 + pendingItem + panelItemName2; |
| rpi.Font.Size = 8; |
| RadPanelItem rpItem = new RadPanelItem(); |
| rpItem.Text = panelItems1; |
| rpItem.Font.Size = 8; |
| rpi.Items.Add(rpItem); |
| RadPanelBar1.Items.Add(rpi); |
| return rpi; |
| } |
| #endregion |
| } |
| <telerik:RadGrid ID="LocationGrid" runat="server" Skin="Web20" OnDeleteCommand="OnLocationDelete" |
| OnInsertCommand="OnLocationInsert" OnItemDeleted="OnLocationItemDeleted" OnItemInserted="OnLocationItemInserted" |
| OnItemUpdated="OnLocationItemUpdated" OnNeedDataSource="OnNeedDataSource" |
| OnUpdateCommand="OnLocationUpdate" ShowStatusBar="True" |
| AutoGenerateColumns="False" GridLines="None" onitemcommand="OnItemCommand"> |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <MasterTableView EditMode="PopUp" CommandItemDisplay="Top"> |
| <Columns> |
| <telerik:GridBoundColumn DataField="ID" UniqueName="colID" Visible="false" DataType="System.Int32"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Description" UniqueName="colDescription" HeaderText="Description"> |
| </telerik:GridBoundColumn> |
| <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="colDelete" HeaderText="Delete"> |
| </telerik:GridButtonColumn> |
| <telerik:GridButtonColumn CommandName="Edit" Text="Edit" UniqueName="colEdit" HeaderText="Edit"> |
| </telerik:GridButtonColumn> |
| </Columns> |
| <EditFormSettings CaptionFormatString="Edit Location" /> |
| </MasterTableView> |
| </telerik:RadGrid> |
| private List<Location> LocationList |
| { |
| get |
| { |
| return Session["LocationList"] as List<Location>; |
| } |
| set |
| { |
| Session["LocationList"] = value; |
| } |
| } |
| private void BuildInitialList() |
| { |
| LocationList = new List<Location> |
| { |
| new Location() {ID = 1, Description = "Some Location"}, |
| new Location() {ID = 2, Description = "Some Other Location"}, |
| }; |
| } |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!Page.IsPostBack) |
| BuildInitialList(); |
| LocationGrid.DataSource = LocationList; |
| LocationGrid.DataBind(); |
| } |
| protected void OnLocationUpdate(object source, Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| GridEditableItem item = e.Item as GridEditableItem; |
| // Description is the old value |
| string Description = (item["colDescription"].Controls[0] as TextBox).Text; |
| // values["Description"] is the old value |
| Dictionary<string, string> values = new Dictionary<string, string>(); |
| item.ExtractValues(values); |
| } |