public void SendMailForNewTicket()
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);

            // Get mail information
            string mailTo = "";
            string nameTo = "";
            string subject = "A support ticket was created.";
            string body = "";

            // MailtTo, nameTo
            int createdBy = Int32.Parse(hdfTeamMemberId.Value);
            EmployeeGateway employeeGateway = new EmployeeGateway();
            employeeGateway.LoadByEmployeeId(createdBy);

            mailTo = employeeGateway.GetEMail(createdBy);
            nameTo = employeeGateway.GetFullName(createdBy);

            // Mails body
            body = body + "\nHi " + nameTo + ",\n\nThe following support ticket was created. \n";
            body = body + "\n Subject: " + hdfSubject.Value;
            body = body + "\n Comment: " + hdfComments.Value;
            body = body + "\n Created By: " + employeeGateway.GetFullName(createdBy);

            if (hdfDueDate.Value != "")
            {
                DateTime dueDate = DateTime.Parse(hdfDueDate.Value);
                string dueDateText = dueDate.Month.ToString() + "/" + dueDate.Day.ToString() + "/" + dueDate.Year.ToString();
                body = body + "\n Due Date: " + dueDateText;
            }

            int categoryId = Int32.Parse(hdfCategoriesSelected.Value);
            SupportTicketCategoryGateway supportTicketCategoryGateway = new SupportTicketCategoryGateway();
            supportTicketCategoryGateway.LoadByCategoryId(categoryId, companyId);
            body = body + "\n Category: " + supportTicketCategoryGateway.GetName(categoryId);

            //int assignTeamMemberId = Int32.Parse(hdfTeamMemberId.Value);
            //EmployeeGateway employeeGatewayForAssignment = new EmployeeGateway();
            //employeeGatewayForAssignment.LoadByEmployeeId(assignTeamMemberId);

            //body = body + "\n Assigned team member: " + employeeGatewayForAssignment.GetFullName(assignTeamMemberId) + "\n";

            body = body + "\n Assigned team member: Anzovino Dan \n";

            //Send Mail
            SendMail(mailTo, subject, body);
        }
        /// <summary>
        /// Save
        /// </summary>
        public void Save()
        {
            foreach (SupportTicketCategoriesAddTDS.CategoriesAddNewRow row in (SupportTicketCategoriesAddTDS.CategoriesAddNewDataTable)Data.Tables["CategoriesAddNew"])
            {
                // Insert category
                if ((!row.Deleted) && (!row.InDatabase))
                {
                    int? parentId = null; if (!row.IsParentIDNull()) parentId = row.ParentID;
                    SupportTicketCategory categories = new SupportTicketCategory(null);
                    categories.InsertDirect(row.Name, parentId, row.Deleted, row.COMPANY_ID);
                }

                // Update category
                if ((!row.Deleted) && (row.InDatabase))
                {
                    int companyId = row.COMPANY_ID;
                    SupportTicketCategoryGateway supportTicketcategoryGateway = new SupportTicketCategoryGateway();
                    supportTicketcategoryGateway.LoadByCategoryId(row.CategoryID, companyId);

                    int categoryId = row.CategoryID;
                    string originalName = supportTicketcategoryGateway.GetName(categoryId);
                    int? originalParentId = null; if (supportTicketcategoryGateway.GetParentId(categoryId).HasValue) originalParentId = (int)supportTicketcategoryGateway.GetParentId(categoryId);

                    SupportTicketCategory category = new SupportTicketCategory(null);
                    category.UpdateDirect(categoryId, originalName, originalParentId, row.Deleted, companyId, row.CategoryID, row.Name, originalParentId, row.Deleted, companyId);
                }

                // Delete category
                if ((row.Deleted) && (row.InDatabase))
                {
                    int categoryId = row.CategoryID;
                    int? newCategoryId = null; if (!row.IsNewCategoryIDNull()) newCategoryId = row.NewCategoryID;
                    int companyId = row.COMPANY_ID;

                    SupportTicketCategory category = new SupportTicketCategory(null);
                    category.DeletedDirect(categoryId, companyId);
                }
            }
        }
 /// <summary>
 /// UpdateDirect
 /// </summary>
 /// <param name="originalSupportTicketCategoryId">originalSupportTicketCategoryId</param>
 /// <param name="originalName">originalName</param>
 /// <param name="originalParentId">originalParentId</param>
 /// <param name="originalDeleted">originalDeleted</param>
 /// <param name="originalCompanyId">originalCompanyId</param>
 /// <param name="newSupportTicketCategoryId">newSupportTicketCategoryId</param>
 /// <param name="newName">newName</param>
 /// <param name="newParentId">newParentId</param>
 /// <param name="newDeleted">newDeleted</param>
 /// <param name="newCompanyId">newCompanyId</param>
 public void UpdateDirect(int originalSupportTicketCategoryId, string originalName, int? originalParentId, bool originalDeleted, int originalCompanyId, int newSupportTicketCategoryId, string newName, int? newParentId, bool newDeleted, int newCompanyId)
 {
     SupportTicketCategoryGateway categoryGateway = new SupportTicketCategoryGateway(null);
     categoryGateway.Update(originalSupportTicketCategoryId,  originalName, originalParentId, originalDeleted, originalCompanyId, newSupportTicketCategoryId, newName, newParentId, newDeleted, newCompanyId);
 }
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// Load
 /// </summary>
 /// <param name="companyId">companyId</param>
 public void Load(int companyId)
 {
     SupportTicketCategoryGateway supportTicketCategoryGateway = new SupportTicketCategoryGateway(Data);
     supportTicketCategoryGateway.Load(companyId);
     UpdateData();
 }
 /// <summary>
 /// InsertDirect
 /// </summary>        
 /// <param name="name">name</param>
 /// <param name="parentId">parentId</param>
 /// <param name="deleted">deleted</param>
 /// <param name="companyId">companyId</param>
 public void InsertDirect(string name, int? parentId, bool deleted, int companyId)
 {
     SupportTicketCategoryGateway categoryGateway = new SupportTicketCategoryGateway(null);
     categoryGateway.Insert(name, parentId, deleted, companyId);
 }
 /// <summary>
 /// DeletedDirect
 /// </summary>
 /// <param name="categoryId">categoryId</param>
 /// <param name="companyId">companyId</param>
 public void DeletedDirect(int categoryId, int companyId)
 {
     SupportTicketCategoryGateway categoryGateway = new SupportTicketCategoryGateway(null);
     categoryGateway.Delete(categoryId, companyId);
 }
        private void PostPageChanges()
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            string subject = hdfSubject.Value;
            string comments = hdfComments.Value;
            DateTime? dueDate = null; if (hdfDueDate.Value != "") dueDate = DateTime.Parse(hdfDueDate.Value);
            int assignTeamMemberId = Int32.Parse(hdfTeamMemberId.Value);
            string state = "New";
            string type_ = "AssignUser";
            int loginId = Convert.ToInt32(Session["loginID"]);
            EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());
            hdfTeamMemberId.Value = employeeGateway.GetEmployeIdByLoginId(loginId).ToString();
            int employeeId = Int32.Parse(hdfTeamMemberId.Value);
            int categoryId = Int32.Parse(hdfCategoriesSelected.Value);
            SupportTicketCategoryGateway supportTicketCategoryGateway = new SupportTicketCategoryGateway();
            supportTicketCategoryGateway.LoadByCategoryId(categoryId, companyId);
            string categoryName = supportTicketCategoryGateway.GetName(categoryId);

            // Insert to dataset
            SupportTicketAddBasicInformation supportTicketAddBasicInformation = new SupportTicketAddBasicInformation(supportTicketAddTDS);
            supportTicketAddBasicInformation.Insert(categoryId, subject, comments, dueDate, assignTeamMemberId, false, companyId, state, employeeId, type_, categoryName);

            // Store session
            Session["supportTicketAddTDS"] = supportTicketAddTDS;
        }
        private string GetSummary()
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);

            string summary = "GENERAL INFORMATION \n";
            summary = summary + "\n Subject: " + hdfSubject.Value + "\n";
            summary = summary + "\n Commnet: " + hdfComments.Value + "\n";
            if (hdfDueDate.Value != "")
            {
                DateTime dueDate = DateTime.Parse(hdfDueDate.Value);
                string dueDateText = dueDate.Month.ToString() + "/" + dueDate.Day.ToString() + "/" + dueDate.Year.ToString();
                summary = summary + "\n Due Date: " + dueDateText + "\n";
            }

            int categoryId = Int32.Parse(hdfCategoriesSelected.Value);
            SupportTicketCategoryGateway supportTicketCategoryGateway = new SupportTicketCategoryGateway();
            supportTicketCategoryGateway.LoadByCategoryId(categoryId, companyId);
            summary = summary + "\n Category: " + supportTicketCategoryGateway.GetName(categoryId) + "\n";

            // Assign Dan Anzovino
            summary = summary + "\nASSIGMENT INFORMATION \n";
            summary = summary + "\n Assigned team member: Dan Anzovino \n";

            // ... Assignation information
            //if ((rbtnAssignToMyself.Checked) || (rbtnAssignToTeamMember.Checked))
            //{
            //    summary = summary + "\nASSIGMENT INFORMATION \n";

            //    // ... ... Assigned Personal
            //    if (hdfAssignToTeamMember.Value == "True")
            //    {
            //        summary = summary + "\n Assigned team member: " + hdfTeamMemberFullName.Value + "\n";
            //    }

            //    // ... ... Asssigned to myself
            //    if (hdfAssignToMyself.Value == "True")
            //    {
            //        summary = summary + "\n Assigned to myself: YES \n";
            //    }
            //}

            return summary;
        }
        private void GetNodeForCategories(TreeNodeCollection nodes, int parentId)
        {
            Int32 thisId;
            String thisName;
            SupportTicketCategoryGateway supportTicketCategoryGateway = new SupportTicketCategoryGateway(null);

            DataRow[] children = supportTicketCategoriesTDS.Tables["LFS_ITTST_CATEGORY"].Select("ParentID='" + parentId + "'");

            //no child nodes, exit function
            if (children.Length == 0) return;

            foreach (DataRow child in children)
            {
                // step 1
                thisId = Convert.ToInt32(child.ItemArray[0]);

                // step 2
                thisName = Convert.ToString(child.ItemArray[1]);

                // step 3
                TreeNode newNode = new TreeNode(thisName, thisId.ToString());
                newNode.ShowCheckBox = true;
                newNode.SelectAction = TreeNodeSelectAction.None;

                //step 4
                //if (supportTicketCategoryGateway.IsUsedInUnitCategory(Int32.Parse(hdfUnitId.Value), thisId))
                //{
                //    newNode.Checked = true;
                //}

                // step 5
                nodes.Add(newNode);
                newNode.ToggleExpandState();

                // step 6
                GetNodeForCategories(newNode.ChildNodes, thisId);
            }
        }
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        // STEP5 - SUMMARY
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP5 - SUMMARY - METHODS
        //
        private void StepSummaryIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "Summary";
            hdfUpdate.Value = "yes";

            if (rbtnAddCategory.Checked) tbxSummary.Text = "Operation: Add category";
            if (rbtnDeleteCategory.Checked) tbxSummary.Text = "Operation: Delete category";
            if (rbtnEditCategory.Checked) tbxSummary.Text = "Operation: Edit category";

            if (!rbtnDeleteCategory.Checked)
            {
                if (arrayCategoriesSelected.Count > 0)
                {
                    foreach (int categoryIdInArray in arrayCategoriesSelected)
                    {
                        SupportTicketCategoryGateway supportTicketcategoryGateway = new SupportTicketCategoryGateway();
                        supportTicketcategoryGateway.LoadByCategoryId(categoryIdInArray, int.Parse(hdfCompanyId.Value));

                        tbxSummary.Text += "\nParent category: " + supportTicketcategoryGateway.GetName(categoryIdInArray);
                    }
                }
                else
                {
                    tbxSummary.Text += "\nParent category: (Empty)";
                }
            }

            if (!rbtnDeleteCategory.Checked)
            {
                tbxSummary.Text += "\nName: " + tbxName.Text;
            }
            else
            {
                foreach (int categoryIdInArray in arrayCategoriesSelected)
                {
                    SupportTicketCategoryGateway supportTicketCategoryGateway = new SupportTicketCategoryGateway();
                    supportTicketCategoryGateway.LoadByCategoryId(categoryIdInArray, int.Parse(hdfCompanyId.Value));

                    tbxSummary.Text += "\nName: " + supportTicketCategoryGateway.GetName(categoryIdInArray);
                }
            }
        }