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) { JobDetailsSessionView jbs = new JobDetailsSessionView(); if (Session["JobDetails"] != null) { jbs = (JobDetailsSessionView)Session["JobDetails"]; if (jbs.IsGenerated != false) { ContractEntity entity = new ContractEntity(); entity.ContractNumber = ContractNumberTextBox.Text; entity.ContractTemplateTitle = jbs.ContractsTemplates[0].Title; entity.OrganizationalUnitId = jbs.OrganisationalUnit.Id; entity.OrganizationalUnitTitle = jbs.OrganisationalUnit.Title; entity.JobCode = jbs.Job.Code; entity.JobTitle = jbs.Job.Title; entity.GradeId = jbs.Grade.Id; #warning changed review and edit //entity.GradeKCB = jbs.Grade.KCB; //entity.GradeEntry = jbs.Grade.Entry; entity.StepId = jbs.Step.Id; //entity.StepEntry = jbs.Step.Entry; entity.OfficiallyApprovedDate = DateTime.Now; entity.FunctionalLevelId = jbs.FunctionalLevel.Id; entity.FunctionalLevelTitle = jbs.FunctionalLevel.Title; entity.EmployeeId = Convert.ToInt32(Request.QueryString["EmployeeId"]); DateTime dt; if (DateTime.TryParseExact(StartDateTextBox.Text, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out dt)) { entity.StartDate = dt; } if (DateTime.TryParseExact(EndDateTextBox.Text, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out dt) == true) { entity.EndDate = dt; entity.Type = ContractType.Limited; TimeSpan span = entity.EndDate.Value.Subtract(entity.StartDate); double years = span.TotalDays / 365; if (years > 10) { StringBuilder sb = new StringBuilder(); sb.Append("<script language='javascript'>displayNoty('The contract that is not idifinite 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 { entity.Type = ContractType.Permanent; } entity.GrossValue = entity.GradeEntry + entity.StepEntry; EmployeeView employeeView = new EmployeeMapper().Get(new EmployeeEntity() { Id = Convert.ToInt32(Request.QueryString["EmployeeId"]) }); entity.EmployeeNo = employeeView.EmployeeNo; entity.EmployeeFirstname = employeeView.Firstname; entity.EmployeeLastname = employeeView.Lastname; entity.EmployeePersonalNumber = employeeView.PersonalNumber; entity.ContractStatus = ContractStatus.Aproved; entity.NextContractNumber = ""; entity.Status = StatusEnum.Active; entity.Content.ContentStatus = StatusEnum.Active; new ContractMapper().Insert(entity); foreach(LanguageEntity lang in new LanguageMapper().ListForContractTemplate(Convert.ToInt32(Request.QueryString["ContractTemplateId"]))) { ContractContentEntity contentEntity = new ContractContentEntity(); contentEntity.Content = ((CKEditor.NET.CKEditorControl)contractVersion.FindControl(lang.Title)).Text; contentEntity.ContractNumber = entity.ContractNumber; contentEntity.LanguageId = lang.Id; new ContractMapper().InsertContent(contentEntity); } jbs.ContractsTemplates.Remove(jbs.ContractsTemplates.Where(s => s.Id == Convert.ToInt32(Request.QueryString["ContractTemplateId"])).First()); if (jbs.ContractsTemplates.Count != 0) { Response.Redirect("Contract.aspx?EmployeeId=" + Request.QueryString["EmployeeId"] + "&ContractTemplateId=" + jbs.ContractsTemplates[0].Id); } else { Response.Redirect("Details.aspx?EmployeeId=" + Request.QueryString["EmployeeId"]); } } } Response.Redirect("List.aspx"); }
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"); } }