Example #1
0
        public AmandamentEntity GetByLanguageId(AmandamentEntity t, int languageId)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;

            try
            {
                conn = DALHelper.CreateSqlDbConnection();
                cmd = new SqlCommand("usp_GetAmandamentById", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@AmandamentId", t.AmandamentId);
                cmd.Parameters.AddWithValue("@LanguageId", languageId);

                SqlDataReader rdr = cmd.ExecuteReader();
                AmandamentEntity entity = new AmandamentEntity();

                while (rdr.Read())
                {
                    entity.AmandamentId = Convert.ToInt32(rdr["AmandamentId"]);
                    entity.ContractNumber = Convert.ToString(rdr["ContractNumber"]);
                    entity.OrganizationalUnitTitle = Convert.ToString(rdr["OrganizationalUnitTitle"]);
                    entity.JobCode = Convert.ToString(rdr["JobCode"]);
                    entity.JobTitle = Convert.ToString(rdr["JobTitle"]);
                    entity.GradeId = Convert.ToString(rdr["GradeId"]);
                    entity.GradeKCB = Convert.ToDouble(rdr["GradeKCB"]);
                    entity.GradeEntry = Convert.ToDouble(rdr["GradeEntry"]);
                    entity.StepId = Convert.ToString(rdr["StepId"]);
                    entity.StepEntry = Convert.ToDouble(rdr["StepEntry"]);
                    entity.OfficiallyApprovedDate = Convert.ToDateTime(rdr["OfficiallyApprovedDate"]);
                    entity.GrossValue = Convert.ToDouble(rdr["GrossValue"]);
                    entity.StartDate = Convert.ToDateTime(rdr["StartDate"]);
                    if (rdr["EndDate"] != DBNull.Value)
                    {
                        entity.EndDate = Convert.ToDateTime(rdr["EndDate"]);
                    }
                    entity.Content.Content = Convert.ToString(rdr["Content"]);
                }

                return entity;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
                conn.Dispose();
            }
        }
Example #2
0
 public AmandamentEntity GetLastAmandament(AmandamentEntity t)
 {
     return GetByLanguageId(ListWithAdvancedFilter(t, StatusEnum.Active)[0], 1);
 }
Example #3
0
 public void Update(AmandamentEntity t)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public AmandamentEntity Get(AmandamentEntity t)
 {
     throw new NotImplementedException();
 }
Example #5
0
        public List<AmandamentEntity> ListWithAdvancedFilter(AmandamentEntity entity, StatusEnum? status)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;

            try
            {
                conn = DALHelper.CreateSqlDbConnection();
                cmd = new SqlCommand("[usp_ListAmandaments]", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@ContractNumber", entity.ContractNumber);
                if (status != null)
                {
                    cmd.Parameters.AddWithValue("@Status", status);
                }

                SqlDataReader rdr = cmd.ExecuteReader();
                List<AmandamentEntity> list = new List<AmandamentEntity>();

                while (rdr.Read())
                {
                    AmandamentEntity view = new AmandamentEntity();
                    view.AmandamentId = Convert.ToInt32(rdr["AmandamentId"]);
                    view.ContractNumber = Convert.ToString(rdr["ContractNumber"]);
                    view.OrganizationalUnitTitle = Convert.ToString(rdr["OrganizationalUnitTitle"]);
                    view.JobTitle = Convert.ToString(rdr["JobTitle"]);
                    view.StartDate = Convert.ToDateTime(rdr["StartDate"]);
                    if (rdr["EndDate"] != DBNull.Value)
                    {
                        view.EndDate = Convert.ToDateTime(rdr["EndDate"]);
                    }
                    list.Add(view);
                }

                return list;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
                conn.Dispose();
            }
        }
Example #6
0
        public void Insert(AmandamentEntity t, int employeeId)
        {
            SqlConnection conn = null;
            SqlCommand cmd = null;

            try
            {
                conn = DALHelper.CreateSqlDbConnection();
                cmd = new SqlCommand("usp_InsertAmandamentWithContent", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                //@Status int,
                //@LanguageId int = 1,

                cmd.Parameters.AddWithValue("@EmployeeId", employeeId);
                cmd.Parameters.AddWithValue("@ContractNumber", t.ContractNumber);

                cmd.Parameters.AddWithValue("@FunctionalLevelId", t.FunctionalLevelId);
                cmd.Parameters.AddWithValue("@FunctionalLevelTitle", t.FunctionalLevelTitle);

                cmd.Parameters.AddWithValue("@OrganizationalUnitId", t.OrganizationalUnitId);
                cmd.Parameters.AddWithValue("@OrganizationalUnitTitle", t.OrganizationalUnitTitle);
                cmd.Parameters.AddWithValue("@JobCode", t.JobCode);
                cmd.Parameters.AddWithValue("@JobTitle", t.JobTitle);

                if (t.GradeId != "")
                {
                    cmd.Parameters.AddWithValue("@GradeId", t.GradeId);
                }
                if (t.GradeKCB != 0)
                {
                    cmd.Parameters.AddWithValue("@GradeKCB", t.GradeKCB);
                }
                if (t.GradeEntry != 0)
                {
                    cmd.Parameters.AddWithValue("@GradeEntry", t.GradeEntry);
                }
                if (t.StepId != "")
                {
                    cmd.Parameters.AddWithValue("@StepId", t.StepId);
                }
                if (t.StepEntry != 0)
                {
                    cmd.Parameters.AddWithValue("@StepEntry", t.StepEntry);
                }

                cmd.Parameters.AddWithValue("@OfficiallyApprovedDate", DateTime.Now);
                cmd.Parameters.AddWithValue("@StartDate", t.StartDate);

                if (t.Type != ContractType.Permanent)
                {
                    cmd.Parameters.AddWithValue("@EndDate", t.EndDate);
                }
                cmd.Parameters.AddWithValue("@IsWithoutEndDate", t.Type);

                cmd.Parameters.AddWithValue("@GrossValue", t.GrossValue);
                cmd.Parameters.AddWithValue("@Status", t.Status);
                //cmd.Parameters.AddWithValue("@LanguageId", t.Content.LanguageId);
                cmd.Parameters.AddWithValue("@Content", t.Content.Content);

                cmd.ExecuteScalar();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
                conn.Dispose();
            }
        }
Example #7
0
 public void Insert(AmandamentEntity t)
 {
     throw new NotImplementedException();
 }
        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");
            }
        }