Example #1
0
        protected void ProceedButton_Click(object sender, EventArgs e)
        {
            string        strings = jsfields.Value;
            StringBuilder stb     = new StringBuilder();

            stb.Append("employeeId=");
            stb.Append(strings);

            List <string> list = strings.Split(',').ToList();

            foreach (string s in list)
            {
                if (!s.StartsWith("0"))
                {
                    int i = Convert.ToInt32(s);

                    EmployeeView employeeView = new EmployeeMapper().Get(new EmployeeEntity()
                    {
                        Id = Convert.ToInt32(s)
                    });

                    ContractEntity lastContract = new ContractMapper().GetLastContract(new ContractEntity()
                    {
                        EmployeeId = employeeView.Id
                    });

                    #warning change the 1 value parameter of getContentById
                    ContractTemplateEntity cte = new ContractTemplateMapper().GetContentById(Convert.ToInt32(ContractTemplateDropDownList.SelectedValue), 1);

                    JobDetailsSessionView   jsv  = new JobDetailsSessionView();
                    CurrentJobDetailsEntity cjde = new CurrentJobDetailsMapper().Get(new CurrentJobDetailsEntity()
                    {
                        EmployeeId = employeeView.Id, ContractNumber = (employeeView.Id + " / " + cte.Preffix)
                    });

                    jsv.FunctionalLevel.Id    = cjde.FunctionalLevelId;
                    jsv.FunctionalLevel.Title = cjde.FunctionalLevelTitle;

                    jsv.Grade.Id = cjde.GradeId;
                    jsv.Grade    = new GradeMapper().Get(jsv.Grade);

                    jsv.Job.Code  = cjde.JobCode;
                    jsv.Job.Title = cjde.JobTitle;

                    jsv.OrganisationalUnit.Id    = cjde.OrganizationalUnitId;
                    jsv.OrganisationalUnit.Title = cjde.OrganizationalUnitTitle;

                    jsv.Step.Id = cjde.StepId;
#warning changed review and edit
                    //jsv.Step.Entry = cjde.StepEntry;

                    if (RadioButtonList1.SelectedItem.Value != "1")
                    {
                        AmandamentTemplateEntity amte = new AmandamentTemplateMapper().GetContentById(Convert.ToInt32(RadioButtonList1.SelectedValue), null);
                        AmandamentEntity         am   = new AmandamentEntity(cjde);

                        am.Status = StatusEnum.Active;

                        am.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(amte.Content, jsv, employeeView);
                        am.ContractNumber  = cjde.ContractNumber;
                        am.Content.Content = am.Content.Content.Replace(@"{#ContractNumber}", am.ContractNumber);

                        new AmandamentMapper().Insert(am, employeeView.Id);
                    }
                    else
                    {
                        ContractEntity ct = new ContractEntity(cjde, employeeView);
                        ct.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(cte.Content, jsv, employeeView);

                        string dt = DateTime.Now.ToString("dd.MM.yyyy");
                        dt = dt.Replace(".", "");
                        ct.ContractNumber = (employeeView.EmployeeNo.Replace("AKP", "") + " / " + cte.Preffix + " / " + dt);

                        ct.Status                 = StatusEnum.Active;
                        ct.ContractStatus         = ContractStatus.Aproved;
                        ct.OfficiallyApprovedDate = DateTime.Now;
                        ct.ContractTemplateTitle  = cte.Preffix;

                        ct.Content.Content = ct.Content.Content.Replace(@"{#ContractNumber}", ct.ContractNumber);
                        new ContractMapper().Insert(ct);
                        new ContractMapper().UpdatePreviousContract(new ContractEntity()
                        {
                            ContractNumber = lastContract.ContractNumber, NextContractNumber = ct.ContractNumber, ContractStatus = Entities.ContractStatus.Changed
                        });
                    }
                }
            }
            if (RadioButtonList1.SelectedItem.Value != "1")
            {
                Response.Redirect("Print.aspx?" + stb + "&type=newAmandament");
            }
            else
            {
                Response.Redirect("Print.aspx?" + stb + "&type=newContract");
            }
        }
        protected void ProceedButton_Click(object sender, EventArgs e)
        {
            string strings = jsfields.Value;
            StringBuilder stb = new StringBuilder();
            stb.Append("employeeId=");
            stb.Append(strings);

            List<string> list = strings.Split(',').ToList();

            DateTime startdt;
            DateTime enddt;
            DateTime.TryParseExact(StartDateTextBox.Text, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out startdt);
            DateTime.TryParseExact(EndDateTextBox.Text, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out enddt);

            foreach (string s in list)
            {
                if (!s.StartsWith("0"))
                {
                    int i = Convert.ToInt32(s);

                    EmployeeView employeeView = new EmployeeMapper().Get(new EmployeeEntity() { Id = Convert.ToInt32(s) });

                    ContractEntity lastContract = new ContractMapper().GetLastContract(new ContractEntity() { EmployeeId = employeeView.Id });

            #warning change the 1 value parameter of getContentById
                    ContractTemplateEntity cte = new ContractTemplateMapper().GetContentById(Convert.ToInt32(ContractTemplateDropDownList.SelectedValue), 1);

                    JobDetailsSessionView jsv = new JobDetailsSessionView();
                    CurrentJobDetailsEntity cjde = new CurrentJobDetailsMapper().Get(new CurrentJobDetailsEntity() { EmployeeId = employeeView.Id, ContractNumber = (employeeView.Id + " / " + cte.Preffix) });

                    jsv.FunctionalLevel.Id = cjde.FunctionalLevelId;
                    jsv.FunctionalLevel.Title = cjde.FunctionalLevelTitle;

                    jsv.Grade.Id = cjde.GradeId;
                    jsv.Grade = new GradeMapper().Get(jsv.Grade);

                    jsv.Job.Code = cjde.JobCode;
                    jsv.Job.Title = cjde.JobTitle;

                    jsv.OrganisationalUnit.Id = cjde.OrganizationalUnitId;
                    jsv.OrganisationalUnit.Title = cjde.OrganizationalUnitTitle;

                    #warning changed review and edit

                    jsv.Step.Id = cjde.StepId;
                    //jsv.Step.Entry = cjde.StepEntry;

                    if (RadioButtonList1.SelectedItem.Value != "1")
                    {
                        AmandamentTemplateEntity amte = new AmandamentTemplateMapper().GetContentById(Convert.ToInt32(RadioButtonList1.SelectedValue), null);
                        AmandamentEntity am = new AmandamentEntity(cjde);

                        am.Status = StatusEnum.Active;

                        am.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(amte.Content, jsv, employeeView);
                        am.ContractNumber = cjde.ContractNumber;
                        am.Content.Content = am.Content.Content.Replace(@"{#ContractNumber}", am.ContractNumber);
                        am.StartDate = startdt;

                        #warning check for contract type Probation if this is first contract it is probation and also check if it is special contract

                        if (enddt != null)
                        {
                            am.EndDate = enddt;
                            am.Type = ContractType.Limited;

                            TimeSpan span = am.EndDate.Value.Subtract(am.StartDate);
                            double years = span.TotalDays / 365;
                            if (years > 10)
                            {
                                StringBuilder sb = new StringBuilder();
                                sb.Append("<script language='javascript'>displayNoty('The amandment that is not for idifinite period cannot be for more than 10 years.');</script>");

                                // if the script is not already registered
                                if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "HeyPopup"))
                                    ClientScript.RegisterClientScriptBlock(Page.GetType(), "HeyPopup", sb.ToString());

                                return;
                            }
                        }
                        else
                        {
                            am.Type = ContractType.Permanent;
                        }

                        new AmandamentMapper().Insert(am, employeeView.Id);
                    }
                    else
                    {
                        ContractEntity ct = new ContractEntity(cjde, employeeView);
                        ct.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(cte.Content, jsv, employeeView);

                        string dt = DateTime.Now.ToString("dd.MM.yyyy");
                        dt = dt.Replace(".", "");
                        ct.ContractNumber = (employeeView.EmployeeNo.Replace("AKP", "") + " / " + cte.Preffix + " / " + dt);

                        ct.Status = StatusEnum.Active;
                        ct.ContractStatus = ContractStatus.Aproved;
                        ct.OfficiallyApprovedDate = DateTime.Now;
                        ct.ContractTemplateTitle = cte.Preffix;

                        ct.Content.Content = ct.Content.Content.Replace(@"{#ContractNumber}", ct.ContractNumber);

                        ct.StartDate = startdt;
                        if (enddt != null)
                        {
                            ct.EndDate = enddt;
                            ct.Type = ContractType.Limited;

                            TimeSpan span = ct.EndDate.Value.Subtract(ct.StartDate);
                            double years = span.TotalDays / 365;
                            if (years > 10)
                            {
                                StringBuilder sb = new StringBuilder();
                                sb.Append("<script language='javascript'>displayNoty('The contract that is not for idifinite period cannot be for more than 10 years.');</script>");

                                // if the script is not already registered
                                if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "HeyPopup"))
                                    ClientScript.RegisterClientScriptBlock(Page.GetType(), "HeyPopup", sb.ToString());

                                return;
                            }
                        }
                        else
                        {
                            ct.Type = ContractType.Permanent;
                        }

            #warning bug please check

                        //new ContractMapper().Insert(ct);

            #warning this dosent exists why
                        //new ContractMapper().UpdatePreviousContract(new ContractEntity() { ContractNumber = lastContract.ContractNumber, NextContractNumber = ct.ContractNumber, ContractStatus = Entities.ContractStatus.Changed, Status = StatusEnum.Pasive });
                    }

                }
            }
            if (RadioButtonList1.SelectedItem.Value != "1")
            {
                Response.Redirect("Print.aspx?" + stb + "&type=newAmandament");

            }
            else
            {
                Response.Redirect("Print.aspx?" + stb + "&type=newContract");
            }
        }
        protected void ProceedButton_Click(object sender, EventArgs e)
        {
            string        strings = jsfields.Value;
            StringBuilder stb     = new StringBuilder();

            stb.Append("employeeId=");
            stb.Append(strings);

            List <string> list = strings.Split(',').ToList();

            DateTime startdt;
            DateTime enddt;

            DateTime.TryParseExact(StartDateTextBox.Text, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out startdt);
            DateTime.TryParseExact(EndDateTextBox.Text, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out enddt);

            foreach (string s in list)
            {
                if (!s.StartsWith("0"))
                {
                    int i = Convert.ToInt32(s);

                    EmployeeView employeeView = new EmployeeMapper().Get(new EmployeeEntity()
                    {
                        Id = Convert.ToInt32(s)
                    });

                    ContractEntity lastContract = new ContractMapper().GetLastContract(new ContractEntity()
                    {
                        EmployeeId = employeeView.Id
                    });

#warning change the 1 value parameter of getContentById
                    ContractTemplateEntity cte = new ContractTemplateMapper().GetContentById(Convert.ToInt32(ContractTemplateDropDownList.SelectedValue), 1);

                    JobDetailsSessionView   jsv  = new JobDetailsSessionView();
                    CurrentJobDetailsEntity cjde = new CurrentJobDetailsMapper().Get(new CurrentJobDetailsEntity()
                    {
                        EmployeeId = employeeView.Id, ContractNumber = (employeeView.Id + " / " + cte.Preffix)
                    });

                    jsv.FunctionalLevel.Id    = cjde.FunctionalLevelId;
                    jsv.FunctionalLevel.Title = cjde.FunctionalLevelTitle;

                    jsv.Grade.Id = cjde.GradeId;
                    jsv.Grade    = new GradeMapper().Get(jsv.Grade);

                    jsv.Job.Code  = cjde.JobCode;
                    jsv.Job.Title = cjde.JobTitle;

                    jsv.OrganisationalUnit.Id    = cjde.OrganizationalUnitId;
                    jsv.OrganisationalUnit.Title = cjde.OrganizationalUnitTitle;

                    #warning changed review and edit

                    jsv.Step.Id = cjde.StepId;
                    //jsv.Step.Entry = cjde.StepEntry;

                    if (RadioButtonList1.SelectedItem.Value != "1")
                    {
                        AmandamentTemplateEntity amte = new AmandamentTemplateMapper().GetContentById(Convert.ToInt32(RadioButtonList1.SelectedValue), null);
                        AmandamentEntity         am   = new AmandamentEntity(cjde);

                        am.Status = StatusEnum.Active;

                        am.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(amte.Content, jsv, employeeView);
                        am.ContractNumber  = cjde.ContractNumber;
                        am.Content.Content = am.Content.Content.Replace(@"{#ContractNumber}", am.ContractNumber);
                        am.StartDate       = startdt;

                        #warning check for contract type Probation if this is first contract it is probation and also check if it is special contract

                        if (enddt != null)
                        {
                            am.EndDate = enddt;
                            am.Type    = ContractType.Limited;

                            TimeSpan span  = am.EndDate.Value.Subtract(am.StartDate);
                            double   years = span.TotalDays / 365;
                            if (years > 10)
                            {
                                StringBuilder sb = new StringBuilder();
                                sb.Append("<script language='javascript'>displayNoty('The amandment that is not for idifinite period cannot be for more than 10 years.');</script>");

                                // if the script is not already registered
                                if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "HeyPopup"))
                                {
                                    ClientScript.RegisterClientScriptBlock(Page.GetType(), "HeyPopup", sb.ToString());
                                }

                                return;
                            }
                        }
                        else
                        {
                            am.Type = ContractType.Permanent;
                        }

                        new AmandamentMapper().Insert(am, employeeView.Id);
                    }
                    else
                    {
                        ContractEntity ct = new ContractEntity(cjde, employeeView);
                        ct.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(cte.Content, jsv, employeeView);

                        string dt = DateTime.Now.ToString("dd.MM.yyyy");
                        dt = dt.Replace(".", "");
                        ct.ContractNumber = (employeeView.EmployeeNo.Replace("AKP", "") + " / " + cte.Preffix + " / " + dt);

                        ct.Status                 = StatusEnum.Active;
                        ct.ContractStatus         = ContractStatus.Aproved;
                        ct.OfficiallyApprovedDate = DateTime.Now;
                        ct.ContractTemplateTitle  = cte.Preffix;

                        ct.Content.Content = ct.Content.Content.Replace(@"{#ContractNumber}", ct.ContractNumber);

                        ct.StartDate = startdt;
                        if (enddt != null)
                        {
                            ct.EndDate = enddt;
                            ct.Type    = ContractType.Limited;

                            TimeSpan span  = ct.EndDate.Value.Subtract(ct.StartDate);
                            double   years = span.TotalDays / 365;
                            if (years > 10)
                            {
                                StringBuilder sb = new StringBuilder();
                                sb.Append("<script language='javascript'>displayNoty('The contract that is not for idifinite period cannot be for more than 10 years.');</script>");

                                // if the script is not already registered
                                if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "HeyPopup"))
                                {
                                    ClientScript.RegisterClientScriptBlock(Page.GetType(), "HeyPopup", sb.ToString());
                                }

                                return;
                            }
                        }
                        else
                        {
                            ct.Type = ContractType.Permanent;
                        }

#warning bug please check

                        //new ContractMapper().Insert(ct);

#warning this dosent exists why
                        //new ContractMapper().UpdatePreviousContract(new ContractEntity() { ContractNumber = lastContract.ContractNumber, NextContractNumber = ct.ContractNumber, ContractStatus = Entities.ContractStatus.Changed, Status = StatusEnum.Pasive });
                    }
                }
            }
            if (RadioButtonList1.SelectedItem.Value != "1")
            {
                Response.Redirect("Print.aspx?" + stb + "&type=newAmandament");
            }
            else
            {
                Response.Redirect("Print.aspx?" + stb + "&type=newContract");
            }
        }
        protected void ProceedButton_Click(object sender, EventArgs e)
        {
            string strings = jsfields.Value;
            StringBuilder stb = new StringBuilder();
            stb.Append("employeeId=");
            stb.Append(strings);

            List<string> list = strings.Split(',').ToList();

            foreach (string s in list)
            {
                if (!s.StartsWith("0"))
                {
                    int i = Convert.ToInt32(s);

                    EmployeeView employeeView = new EmployeeMapper().Get(new EmployeeEntity() { Id = Convert.ToInt32(s) });

                    ContractEntity lastContract = new ContractMapper().GetLastContract(new ContractEntity() { EmployeeId = employeeView.Id });

                    #warning change the 1 value parameter of getContentById
                    ContractTemplateEntity cte = new ContractTemplateMapper().GetContentById(Convert.ToInt32(ContractTemplateDropDownList.SelectedValue), 1);

                    JobDetailsSessionView jsv = new JobDetailsSessionView();
                    CurrentJobDetailsEntity cjde = new CurrentJobDetailsMapper().Get(new CurrentJobDetailsEntity() { EmployeeId = employeeView.Id, ContractNumber = (employeeView.Id + " / " + cte.Preffix) });

                    jsv.FunctionalLevel.Id = cjde.FunctionalLevelId;
                    jsv.FunctionalLevel.Title = cjde.FunctionalLevelTitle;

                    jsv.Grade.Id = cjde.GradeId;
                    jsv.Grade = new GradeMapper().Get(jsv.Grade);

                    jsv.Job.Code = cjde.JobCode;
                    jsv.Job.Title = cjde.JobTitle;

                    jsv.OrganisationalUnit.Id = cjde.OrganizationalUnitId;
                    jsv.OrganisationalUnit.Title = cjde.OrganizationalUnitTitle;

                    jsv.Step.Id = cjde.StepId;
            #warning changed review and edit
                    //jsv.Step.Entry = cjde.StepEntry;

                    if (RadioButtonList1.SelectedItem.Value != "1")
                    {
                        AmandamentTemplateEntity amte = new AmandamentTemplateMapper().GetContentById(Convert.ToInt32(RadioButtonList1.SelectedValue), null);
                        AmandamentEntity am = new AmandamentEntity(cjde);

                        am.Status = StatusEnum.Active;

                        am.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(amte.Content, jsv, employeeView);
                        am.ContractNumber = cjde.ContractNumber;
                        am.Content.Content = am.Content.Content.Replace(@"{#ContractNumber}", am.ContractNumber);

                        new AmandamentMapper().Insert(am, employeeView.Id);
                    }
                    else
                    {
                        ContractEntity ct = new ContractEntity(cjde, employeeView);
                        ct.Content.Content = new GUIHelper().ReplaceTemplateContractWithConcreteContract(cte.Content, jsv, employeeView);

                        string dt = DateTime.Now.ToString("dd.MM.yyyy");
                        dt = dt.Replace(".", "");
                        ct.ContractNumber = (employeeView.EmployeeNo.Replace("AKP", "") + " / " + cte.Preffix + " / " + dt);

                        ct.Status = StatusEnum.Active;
                        ct.ContractStatus = ContractStatus.Aproved;
                        ct.OfficiallyApprovedDate = DateTime.Now;
                        ct.ContractTemplateTitle = cte.Preffix;

                        ct.Content.Content = ct.Content.Content.Replace(@"{#ContractNumber}", ct.ContractNumber);
                        new ContractMapper().Insert(ct);
                        new ContractMapper().UpdatePreviousContract(new ContractEntity() { ContractNumber = lastContract.ContractNumber, NextContractNumber = ct.ContractNumber, ContractStatus = Entities.ContractStatus.Changed });
                    }

                }
            }
            if (RadioButtonList1.SelectedItem.Value != "1")
            {
                Response.Redirect("Print.aspx?" + stb + "&type=newAmandament");

            }
            else
            {
                Response.Redirect("Print.aspx?" + stb + "&type=newContract");
            }
        }