protected void btnDraft_Click(object sender, EventArgs e)
    {
        using (EmployeeJournal objEmployeeJournal = new EmployeeJournal())
        {

            if (objEmployeeJournal.Update() > 0)
            {
                Response.Redirect("EmployeeJournalList.aspx");
            }
        }
    }
    protected void btnFinalize_Click(object sender, EventArgs e)
    {
        ViewState["JournalCode"] = Request.QueryString["JournalCode"];
        if (lblReviewer.ForeColor == Color.Black)
        {
            string confirmValue = Request.Form["confirm_value"];
            if (confirmValue == "Yes")
            {
                using (EmployeeJournal objEmployeeJournal = new EmployeeJournal())
                {
                    objEmployeeJournal.EmployeeJournalCode = Convert.ToInt16(Request.QueryString["JournalCode"]);
                    objEmployeeJournal.JournalStatus       = "F";
                    objEmployeeJournal.LockStatus          = "1";
                    objEmployeeJournal.Enabled             = "1";
                    objEmployeeJournal.Contents            = ckeContents.Text.Replace("style=\"display: none\"", "");
                    objEmployeeJournal.ModifiedBy          = Request.Cookies["Speedo"]["UserName"].ToString();
                    if (objEmployeeJournal.UpdateStatus() > 0)
                    {
                        using (EmployeeJournalApproval objEmployeeJournalApproval = new EmployeeJournalApproval())
                        {
                            objEmployeeJournalApproval.EmployeeJournalCode = objEmployeeJournal.EmployeeJournalCode;
                            objEmployeeJournalApproval.JournalApprover     = EmployeeReviewer.GetReviewer(Request.Cookies["Speedo"]["UserName"].ToString());
                            objEmployeeJournalApproval.JournalAStatus      = "F";
                            objEmployeeJournalApproval.JournalAOrder       = 1;
                            objEmployeeJournalApproval.JournalADate        = DateTime.Now;
                            objEmployeeJournalApproval.Insert();

                            objEmployeeJournal.SendNotification(EmployeeJournal.EJSMailType.FiledAcknowledgementRequestor, Request.Cookies["Speedo"]["UserName"].ToString(), EmployeeReviewer.GetReviewer(Request.Cookies["Speedo"]["UserName"].ToString()));
                            objEmployeeJournal.SendNotification(EmployeeJournal.EJSMailType.FiledNotificationApprover, Request.Cookies["Speedo"]["UserName"].ToString(), EmployeeReviewer.GetReviewer(Request.Cookies["Speedo"]["UserName"].ToString()));
                        }
                        Response.Redirect("EmployeeJournalList.aspx");
                    }
                }
            }
            else
            {
                using (EmployeeJournal objEmployeeJournal = new EmployeeJournal())
                {
                    objEmployeeJournal.EmployeeJournalCode = Convert.ToInt16(Request.QueryString["JournalCode"]);
                    objEmployeeJournal.Contents            = ckeContents.Text;
                    objEmployeeJournal.ModifiedBy          = Request.Cookies["Speedo"]["UserName"].ToString();
                    objEmployeeJournal.ModifiedOn          = DateTime.Now;

                    if (objEmployeeJournal.Update() > 0)
                    {
                        Response.Redirect("JournalEncoding.aspx?JournalCode=" + Request.QueryString["JournalCode"]);
                    }
                }
            }
        }
    }
    protected void btnPreview_Click(object sender, EventArgs e)
    {
        using (EmployeeJournal objEmployeeJournal = new EmployeeJournal())
        {
            //objEmployeeJournal.EmployeeJournalCode = EmployeeJournal.GetLastJournalCode(Convert.ToInt16(WeekYear.GetActiveWeekCode()), Request.Cookies["Speedo"]["UserName"].ToString());
            objEmployeeJournal.EmployeeJournalCode = Convert.ToInt16(Request.QueryString["JournalCode"]);
            objEmployeeJournal.Contents            = ckeContents.Text.Replace("style=\"display: none\"", "");
            objEmployeeJournal.ModifiedBy          = Request.Cookies["Speedo"]["UserName"].ToString();
            objEmployeeJournal.ModifiedOn          = DateTime.Now;

            if (objEmployeeJournal.Update() > 0)
            {
                Response.Redirect("JournalViewer.aspx?JournalCode=" + Request.QueryString["JournalCode"]);
            }
        }
    }
        protected override void SubscribeEvent()
        {
            View.Loading += View_Loading;


            View.OutputJopTicket             += View_OutputJopTicket;
            View.OutputCertificateCompletion += View_OutputCertificateCompletion;
            View.OutputAcceptanceTransferOwnershipCertificate += View_OutputAcceptanceTransferOwnershipCertificate;


            View.SeachEmployee     += a => _usersJournal.Filter(a);
            View.SeachWorkingHour  += a => _workingHoursJournal.Filter(a);
            View.SeachUnit         += a => _unitsJournal.Filter(a);
            View.SeachNomenclature += a => _nomenclaturesJournal.Filter(a);
            View.SeachOption       += a => _optionsJournal.Filter(a);
            View.SeachReason       += a => _reasonsJournal.Filter(a);
            View.SeachMark         += a => _marksJournal.Filter(a);
            View.SeachModel        += a => _modelsJournal.Filter(a);
            View.SeachContractor   += a => _contractorsJournal.Filter(a);
            View.SeachApplication  += a => _applicationsJournal.Filter(a);


            View.UpdateEmployee += async() => await _usersJournal.Update();

            View.UpdateWorkingHour += async() => await _workingHoursJournal.Update();

            View.UpdateUnit += async() => await _unitsJournal.Update();

            View.UpdateNomenclature += async() => await _nomenclaturesJournal.Update();

            View.UpdateOption += async() => await _optionsJournal.Update();

            View.UpdateReason += async() => await _reasonsJournal.Update();

            View.UpdateMark += async() => await _marksJournal.Update();

            View.UpdateModel += async() => await _modelsJournal.Update();

            View.UpdateContractor += async() => await _contractorsJournal.Update();

            View.UpdateApplication += async() => await _applicationsJournal.Update();


            View.AddEmployee += async() => await _usersJournal.AddRecord();

            View.AddWorkingHour += async() => await _workingHoursJournal.AddRecord();

            View.AddUnit += async() => await _unitsJournal.AddRecord();

            View.AddNomenclature += async() => await _nomenclaturesJournal.AddRecord();

            View.AddOption += async() => await _optionsJournal.AddRecord();

            View.AddReason += async() => await _reasonsJournal.AddRecord();

            View.AddMark += async() => await _marksJournal.AddRecord();

            View.AddModel += async() => await _modelsJournal.AddRecord();

            View.AddContractor += async() => await _contractorsJournal.AddRecord();

            View.AddApplication += async() => await _applicationsJournal.AddRecord();


            View.EditEmployee += async() => await _usersJournal.EditRecord();

            View.EditWorkingHour += async() => await _workingHoursJournal.EditRecord();

            View.EditUnit += async() => await _unitsJournal.EditRecord();

            View.EditNomenclature += async() => await _nomenclaturesJournal.EditRecord();

            View.EditOption += async() => await _optionsJournal.EditRecord();

            View.EditReason += async() => await _reasonsJournal.EditRecord();

            View.EditMark += async() => await _marksJournal.EditRecord();

            View.EditModel += async() => await _modelsJournal.EditRecord();

            View.EditContractor += async() => await _contractorsJournal.EditRecord();

            View.EditApplication += async() => await _applicationsJournal.EditRecord();


            View.DeleteEmployee += async() => await _usersJournal.DeleteRecord();

            View.DeleteWorkingHour += async() => await _workingHoursJournal.DeleteRecord();

            View.DeleteUnit += async() => await _unitsJournal.DeleteRecord();

            View.DeleteNomenclature += async() => await _nomenclaturesJournal.DeleteRecord();

            View.DeleteOption += async() => await _optionsJournal.DeleteRecord();

            View.DeleteReason += async() => await _reasonsJournal.DeleteRecord();

            View.DeleteMark += async() => await _marksJournal.DeleteRecord();

            View.DeleteModel += async() => await _modelsJournal.DeleteRecord();

            View.DeleteContractor += async() => await _contractorsJournal.DeleteRecord();

            View.DeleteApplication += async() => await _applicationsJournal.DeleteRecord();
        }