コード例 #1
0
ファイル: ContractMapper.cs プロジェクト: apkalexei/HRMS
        public void InsertContent(ContractContentEntity t)
        {
            SqlConnection conn = null;
            SqlCommand    cmd  = null;

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

                cmd.Parameters.AddWithValue("@ContractNumber", t.ContractNumber);
                cmd.Parameters.AddWithValue("@LanguageId", t.LanguageId);
                cmd.Parameters.AddWithValue("@Content", t.Content);

                cmd.ExecuteScalar();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
                conn.Dispose();
            }
        }
コード例 #2
0
ファイル: ContractMapper.cs プロジェクト: apkalexei/HRMS
        public List <ContractContentEntity> ListLastContractsContents(ContractEntity t)
        {
            SqlConnection conn = null;
            SqlCommand    cmd  = null;

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

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

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

                while (rdr.Read())
                {
                    ContractContentEntity view = new ContractContentEntity();
                    view.Content = Convert.ToString(rdr["Content"]);
                    list.Add(view);
                }

                return(list);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
                conn.Dispose();
            }
        }
コード例 #3
0
ファイル: Contract.aspx.cs プロジェクト: apkalexei/HRMS
        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");
        }