private void UpdateDatabase()
        {
            // Get ids
            int companyId = Int32.Parse(hdfCompanyId.Value);

            DB.Open();
            DB.BeginTransaction();
            try
            {
                // ... Update general todo list state
                SupportTicketInformationBasicInformation supportTicketInformationBasicInformation = new SupportTicketInformationBasicInformation(supportTicketInformationTDS);
                supportTicketInformationBasicInformation.Save(companyId);

                // ... Save to do list details
                SupportTicketInformationActivityInformation supportTicketInformationActivityInformation = new SupportTicketInformationActivityInformation(supportTicketInformationTDS);
                supportTicketInformationActivityInformation.Save(companyId);

                // ... Send mails
                int createdBy = Int32.Parse(hdfCreatedById.Value);
                string mailTo = "";
                string nameTo = "";

                // ... ... MailtTo, nameTo
                EmployeeGateway employeeGateway = new EmployeeGateway();
                employeeGateway.LoadByEmployeeId(createdBy);

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

                SupportTicketInformationActivityInformation supportTicketInformationActivityInformationForMails = new SupportTicketInformationActivityInformation(supportTicketInformationTDS);

                foreach (GridViewRow row in grdSupportTicket.Rows)
                {
                    bool sendMail = bool.Parse(((Label)row.FindControl("lblSendMail")).Text);

                    if (sendMail)
                    {
                        string subject = "";
                        string body = "";
                        string comment = "";

                        string type_ = ((Label)row.FindControl("lblType")).Text;
                        switch (type_)
                        {
                            case "AssignUser":
                                // Get mail information
                                subject = "A usser was assigned to the following ticket.";

                                // Mails body
                                body = body + "\nHi " + nameTo + ",\n\nA usser was assigned to the following ticket. \n";
                                body = body + "\n Subject: " + lblTitleSubjectName.Text;
                                body = body + "\n Created By: " + tbxCreatedBy.Text;
                                body = body + "\n Creation Date: " + tbxCreationDate.Text;
                                body = body + "\n Category: " + tbxCategoryName.Text;
                                string assignedUser = ((TextBox)row.FindControl("tbxUser")).Text;
                                body = body + "\n Assigned User: "******"\n Due Date: " + tbxDueDate.Text;
                                comment = ((TextBox)row.FindControl("tbxComments")).Text;
                                body = body + "\n New comment: " + comment;

                                //Send Mail
                                SendMail(mailTo, subject, body);
                                break;

                            case "AssignToOwner":
                                // Get mail information
                                subject = "The following ticket was assigned to it's owner.";

                                // Mails body
                                body = body + "\nHi " + nameTo + ",\n\nThe following ticket was assigned to it's owner. \n";
                                body = body + "\n Subject: " + lblTitleSubjectName.Text;
                                body = body + "\n Owner: " + tbxCreatedBy.Text;
                                body = body + "\n Creation Date: " + tbxCreationDate.Text;
                                body = body + "\n Category: " + tbxCategoryName.Text;
                                string assignedOwer = ((TextBox)row.FindControl("tbxUser")).Text;
                                body = body + "\n Assigned To Owner: " + assignedOwer;
                                body = body + "\n Due Date: " + tbxDueDate.Text;
                                comment = ((TextBox)row.FindControl("tbxComments")).Text;
                                body = body + "\n New comment: " + comment;

                                //Send Mail
                                SendMail(mailTo, subject, body);
                                break;

                            case "AddComment":
                                // Get mail information
                                subject = "A comment was added to the following ticket.";

                                // Mails body
                                body = body + "\nHi " + nameTo + ",\n\nA comment was added to the following ticket. \n";
                                body = body + "\n Subject: " + lblTitleSubjectName.Text;
                                body = body + "\n Created By: " + tbxCreatedBy.Text;
                                body = body + "\n Creation Date: " + tbxCreationDate.Text;
                                body = body + "\n Category: " + tbxCategoryName.Text;
                                body = body + "\n Assigned User: "******"\n Due Date: " + tbxDueDate.Text;
                                string commentAddedBy = ((TextBox)row.FindControl("tbxUser")).Text;
                                body = body + "\n Comment added by: " + commentAddedBy;
                                comment = ((TextBox)row.FindControl("tbxComments")).Text;
                                body = body + "\n New comment: " + comment;

                                //Send Mail
                                SendMail(mailTo, subject, body);
                                break;

                            case "CloseTicket":
                                // Get mail information
                                subject = "A support ticket was completed.";

                                // Mails body
                                body = body + "\nHi " + nameTo + ",\n\nThe following support ticket was completed. \n";
                                body = body + "\n Subject: " + lblTitleSubjectName.Text;
                                body = body + "\n Created By: " + tbxCreatedBy.Text;
                                body = body + "\n Creation Date: " + tbxCreationDate.Text;
                                body = body + "\n Category: " + tbxCategoryName.Text;
                                body = body + "\n Assigned User: "******"\n Due Date: " + tbxDueDate.Text;
                                string completedBy = ((TextBox)row.FindControl("tbxUser")).Text;
                                body = body + "\n Completed by: " + completedBy;
                                comment = ((TextBox)row.FindControl("tbxComments")).Text;
                                body = body + "\n New comment: " + comment;

                                //Send Mail
                                SendMail(mailTo, subject, body);
                                break;

                            case "OnHold":
                                // Get mail information
                                subject = "The following ticket was put on hold.";

                                // Mails body
                                body = body + "\nHi " + nameTo + ",\n\nThe following ticket was put on hold. \n";
                                body = body + "\n Subject: " + lblTitleSubjectName.Text;
                                body = body + "\n Created By: " + tbxCreatedBy.Text;
                                body = body + "\n Creation Date: " + tbxCreationDate.Text;
                                body = body + "\n Category: " + tbxCategoryName.Text;
                                body = body + "\n Assigned User: "******"\n Due Date: " + tbxDueDate.Text;
                                string onHoldBy = ((TextBox)row.FindControl("tbxUser")).Text;
                                body = body + "\n On hold by: " + onHoldBy;
                                comment = ((TextBox)row.FindControl("tbxComments")).Text;
                                body = body + "\n New comment: " + comment;

                                //Send Mail
                                SendMail(mailTo, subject, body);
                                break;
                        }
                    }
                }

                DB.CommitTransaction();

                // Store datasets
                supportTicketInformationTDS.AcceptChanges();
                Session["supportTicketInformationTDS"] = supportTicketInformationTDS;
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }