コード例 #1
0
ファイル: Step6.ascx.cs プロジェクト: syurov/rt.srz
        /// <summary>
        /// The move data from gui 2 object.
        /// </summary>
        /// <param name="statement">
        /// The statement.
        /// </param>
        /// <param name="setCurrentStatement">
        /// The set current statement.
        /// </param>
        public override void MoveDataFromGui2Object(ref Statement statement, bool setCurrentStatement = true)
        {
            if (statement.MedicalInsurances == null)
            {
                statement.MedicalInsurances = new List <MedicalInsurance>(2);
            }

            foreach (var medicalInsurance in statement.MedicalInsurances)
            {
                medicalInsurance.IsActive = false;
            }

            // Выдача ВС
            if (statement.AbsentPrevPolicy.HasValue && statement.AbsentPrevPolicy.Value)
            {
                var temp = statement.MedicalInsurances.FirstOrDefault(x => x.PolisType.Id == PolisType.В);
                if (temp == null)
                {
                    temp = new MedicalInsurance();
                    statement.MedicalInsurances.Add(temp);
                }

                temp.IsActive      = true;
                temp.PolisType     = regulatoryService.GetConcept(PolisType.В);
                temp.PolisSeria    = string.Empty;
                temp.PolisNumber   = tbTemporaryCertificateNumber.Text;
                temp.Statement     = statement;
                temp.StateDateTo   = new DateTime(2200, 1, 1);
                temp.StateDateFrom = DateTime.Now;

                // Дата выдачи ВС
                DateTime dateTime;
                temp.DateFrom = !string.IsNullOrEmpty(tbTemporaryCertificateDateIssue.Text) &&
                                DateTime.TryParse(tbTemporaryCertificateDateIssue.Text, out dateTime)
                          ? dateTime
                          : new DateTime(1900, 1, 1);

                temp.DateTo   = statementService.CalculateEndPeriodWorkingDay(temp.DateFrom, 30);
                temp.DateStop = PolisEndDate != new DateTime(2200, 1, 1) ? (DateTime?)PolisEndDate : null;
            }

            // Выдача полиса
            statement.PolicyIsIssued = chbPolicyIsIssued.Checked;
            if (statement.PolicyIsIssued.Value)
            {
                var polis = statement.MedicalInsurances.FirstOrDefault(x => x.PolisType.Id != PolisType.В);
                if (polis == null)
                {
                    polis = new MedicalInsurance();
                    statement.MedicalInsurances.Add(polis);
                }

                polis.IsActive = true;
                var policyType = int.Parse(ddlPolicyType.SelectedValue);
                polis.PolisType     = regulatoryService.GetConcept(policyType);
                polis.PolisSeria    = string.Empty;
                polis.PolisNumber   = tbPolicyNumber.Text;
                polis.Enp           = tbEnpNumber.Text;
                polis.Statement     = statement;
                polis.StateDateTo   = new DateTime(2200, 1, 1);
                polis.StateDateFrom = DateTime.Now;

                // Дата выдачи ВС
                DateTime dateTime;
                polis.DateFrom = !string.IsNullOrEmpty(tbPolicyDateIssue.Text) &&
                                 DateTime.TryParse(tbPolicyDateIssue.Text, out dateTime)
                           ? dateTime
                           : new DateTime(2011, 1, 1);

                // Дата окончания действия
                polis.DateTo = !string.IsNullOrEmpty(tbPolicyDateEnd.Text) &&
                               DateTime.TryParse(tbPolicyDateEnd.Text, out dateTime)
                         ? dateTime
                         : new DateTime(2200, 1, 1);
                polis.DateStop = null;
            }

            // сохранение изменений в сессию
            if (setCurrentStatement)
            {
                CurrentStatement = statement;
            }
        }
コード例 #2
0
 /// <summary>
 /// Вычисляет дату окончания 30 рабочих дней
 /// </summary>
 /// <param name="dateFrom">
 /// The date from.
 /// </param>
 /// <param name="count">
 /// The count.
 /// </param>
 /// <returns>
 /// The <see cref="DateTime"/>.
 /// </returns>
 public DateTime CalculateEndPeriodWorkingDay(DateTime dateFrom, int count)
 {
     return(InvokeInterceptors(() => Service.CalculateEndPeriodWorkingDay(dateFrom, count)));
 }