protected void btnFinalize_Click(object sender, EventArgs e)
 {
     using (EmployeeJournal objEmployeeJournal = new EmployeeJournal())
     {
         objEmployeeJournal.EmployeeJournalCode = EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString());
         objEmployeeJournal.JournalStatus = "F";
         objEmployeeJournal.LockStatus = "1";
         objEmployeeJournal.Enabled = "1";
         objEmployeeJournal.ModifiedBy = Request.Cookies["Speedo"]["UserName"].ToString();
         if (objEmployeeJournal.UpdateStatus() > 0)
         {
             using (EmployeeJournalApproval objEmployeeJournalApproval = new EmployeeJournalApproval())
             {
                 objEmployeeJournalApproval.EmployeeJournalCode = objEmployeeJournal.EmployeeJournalCode;
                 objEmployeeJournalApproval.JournalApprover = ddlDeptHead.SelectedValue.ToString();
                 objEmployeeJournalApproval.JournalAStatus = "F";
                 objEmployeeJournalApproval.JournalAOrder = 1;
                 objEmployeeJournalApproval.JournalADate = DateTime.Now;
                 objEmployeeJournalApproval.Insert();
                 
                 objEmployeeJournalApproval.EmployeeJournalCode = objEmployeeJournal.EmployeeJournalCode;
                 objEmployeeJournalApproval.JournalApprover = ddlDivHead.SelectedValue.ToString();
                 objEmployeeJournalApproval.JournalAStatus = "F";
                 objEmployeeJournalApproval.JournalAOrder = 2;
                 objEmployeeJournalApproval.JournalADate = DateTime.Now;
                 objEmployeeJournalApproval.Insert();
             }
             Response.Redirect("EmployeeJournalList.aspx");
         }
     }
 }
    protected void MakeCart()
    {
        DataTable tblCart = new DataTable("Cart");
        tblCart.Columns.Add("JournalDCode", System.Type.GetType("System.String"));
        tblCart.Columns.Add("JournalCode", System.Type.GetType("System.String"));
        tblCart.Columns.Add("ItemNumber", System.Type.GetType("System.String"));
        tblCart.Columns.Add("Contents", System.Type.GetType("System.String"));
        tblCart = EmployeeJournalDetails.GetDSGCart(EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString()));
        ViewState["Cart"] = tblCart;

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

        using (EmployeeJournal objEmployeeJournal = new EmployeeJournal())
        {
            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
            {
                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");
                }
            }
        }
    }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     using (EmployeeJournalDetails objEmployeeJournalDetails = new EmployeeJournalDetails())
     {
         objEmployeeJournalDetails.EmployeeJournalCode = EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString());
         objEmployeeJournalDetails.Contents            = txtContents.Text;
         objEmployeeJournalDetails.ItemNumber          = EmployeeJournalDetails.GetTotalRecords(EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString())) + 1;
         objEmployeeJournalDetails.JournalDate         = DateTime.Now;
         objEmployeeJournalDetails.CreatedOn           = DateTime.Now;
         objEmployeeJournalDetails.EndorsedBy          = "NA";
         objEmployeeJournalDetails.EndorsedOn          = DateTime.Now;
         objEmployeeJournalDetails.EndoredRemarks      = "NA";
         objEmployeeJournalDetails.ApprovedBy          = "NA";
         objEmployeeJournalDetails.ApprovedOn          = DateTime.Now;
         objEmployeeJournalDetails.ApprovedRemarks     = "NA";
         objEmployeeJournalDetails.JournalStatus       = "F";
         objEmployeeJournalDetails.IsEnabled           = "1";
         if (objEmployeeJournalDetails.Insert() > 0)
         {
             Response.Redirect("JournalEncodingM.aspx?JournalCode=" + ViewState["JournalCode"].ToString());
         }
     }
 }