protected void btnGoToJournal_Click(object sender, EventArgs e)
    {
        string strLink = "";

        using (EmployeeJournal objEmployeeJournal = new EmployeeJournal())
        {
            try
            {
                foreach (DataRow drUncreatedJournal in EmployeeJournal.GetDSGUncreatedJournal(Request.Cookies["Speedo"]["UserName"]).Rows)
                {
                    objEmployeeJournal.WeekCode   = Convert.ToInt16(drUncreatedJournal["WeekCode"]);
                    objEmployeeJournal.Enabled    = "1";
                    objEmployeeJournal.CreatedBy  = Request.Cookies["Speedo"]["UserName"].ToString();
                    objEmployeeJournal.CreatedOn  = DateTime.Now;
                    objEmployeeJournal.ModifiedBy = Request.Cookies["Speedo"]["UserName"].ToString();
                    objEmployeeJournal.ModifiedOn = DateTime.Now;
                    objEmployeeJournal.Insert();
                }

                if (EmployeeJournal.HasExistingJournal(Request.Cookies["Speedo"]["UserName"].ToString(), Convert.ToInt16(WeekYear.GetActiveWeekCode())))
                {
                    if (EmployeeJournal.GetJournalStatus(Convert.ToInt16(EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()))).ToString() == "S" && EmployeeJournal.GetLockStatus(Convert.ToInt16(EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()))).ToString() == "0")
                    {
                        strLink = "JournalEncoding";
                        Response.Redirect("JournalEncoding.aspx?JournalCode=" + EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()).ToString());
                    }
                    else if (EmployeeJournal.GetJournalStatus(Convert.ToInt16(EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()))).ToString() == "F" && EmployeeJournal.GetLockStatus(Convert.ToInt16(EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()))).ToString() == "0")
                    {
                        strLink = "JournalEncodingM";
                        Response.Redirect("JournalEncodingM.aspx?JournalCode=" + EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()).ToString());
                    }
                    else
                    {
                        strLink = "JournalViewer";
                        Response.Redirect("JournalViewer.aspx?JournalCode=" + EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()).ToString());
                    }
                }
                else
                {
                    try
                    {
                        objEmployeeJournal.WeekCode   = Convert.ToInt16(WeekYear.GetActiveWeekCode());
                        objEmployeeJournal.Enabled    = "1";
                        objEmployeeJournal.CreatedBy  = Request.Cookies["Speedo"]["UserName"].ToString();
                        objEmployeeJournal.CreatedOn  = DateTime.Now;
                        objEmployeeJournal.ModifiedBy = Request.Cookies["Speedo"]["UserName"].ToString();
                        objEmployeeJournal.ModifiedOn = DateTime.Now;
                        if (objEmployeeJournal.Insert() > 0)
                        {
                            //Response.Redirect("JournalEncoding.aspx");
                            //Response.Redirect("JournalEncoding.aspx?JournalCode=" + EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()).ToString());

                            Response.Redirect("JournalEncoding.aspx?JournalCode=" + EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()).ToString());
                        }
                    }
                    catch
                    {
                        //Response.Redirect("JournalUnavailable.aspx");
                        Response.Redirect("EmployeeJournalList.aspx");
                    }
                }
            }
            catch
            {
            }
        }
    }