/// <summary>
        /// Transfer to History
        /// </summary>
        /// <param name="loginId">loginId</param>
        /// <param name="adminPermission">admin Permission</param>
        /// <param name="jlinerHistory">jlinerHistory</param>
        public void transferToHistory(int loginId, bool adminPermission, FlatSectionJlinerJuntionLiner2History jlinerHistory)
        {
            foreach (FlatSectionJlinerTDS.JuntionLiner2CommentRow commentRow in (FlatSectionJlinerTDS.JuntionLiner2CommentDataTable)Table)
            {
                if (adminPermission)
                {
                    if ((commentRow.toHistory) && (!commentRow.Deleted))
                    {
                        // Insert to history
                        jlinerHistory.Insert(commentRow.ID, commentRow.RefID, commentRow.COMPANY_ID, commentRow.DateTime_, commentRow.LoginID, commentRow.Comment, commentRow.Deleted, false, false);

                        // Delete from comments
                        commentRow.Deleted = true;
                    }
                }
                else
                {
                    if (commentRow.LoginID == loginId)
                    {
                        if ((commentRow.toHistory) && (!commentRow.Deleted))
                        {
                            // Insert to history
                            jlinerHistory.Insert(commentRow.ID, commentRow.RefID, commentRow.COMPANY_ID, commentRow.DateTime_, commentRow.LoginID, commentRow.Comment, commentRow.Deleted, false, false);

                            // Delete from comments
                            commentRow.Deleted = true;
                        }
                    }
                }
            }
        }
        private void GrdHistoryAdd()
        {
            if (ValidateHistoryFooter())
            {
                Page.Validate("commentsDataAdd");
                if (Page.IsValid)
                {
                    Guid id = new Guid(hdfId.Value);
                    int refId = Convert.ToInt32(hdfRefId.Value);

                    int companyId = Int32.Parse(hdfCompanyId.Value);
                    int loginId = Convert.ToInt32(Session["loginID"]);
                    DateTime dateTime_ = DateTime.Now;
                    bool inDatabase = false;
                    bool deleted = false;

                    string newComment = ((TextBox)grdHistory.FooterRow.FindControl("tbxHistoryNew")).Text.Trim();
                    bool toComments = ((CheckBox)grdHistory.FooterRow.FindControl("ckbxToCommentsNew")).Checked;

                    LoginGateway loginGateway = new LoginGateway();
                    loginGateway.LoadByLoginId(loginId, companyId);
                    string userFullName = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId);

                    FlatSectionJlinerJuntionLiner2History model = new FlatSectionJlinerJuntionLiner2History(flatSectionJlinerTDS);
                    model.Insert(id, refId, companyId, dateTime_, loginId, newComment, deleted, toComments, inDatabase);

                    Session.Remove("historyDummy");
                    Session["flatSectionJlinerTDS"] = flatSectionJlinerTDS;
                    Session["history"] = flatSectionJlinerTDS.JuntionLiner2History;

                    grdHistory.DataBind();
                    grdHistory.PageIndex = grdHistory.PageCount - 1;
                }
            }
        }