ToDateTime() public static method

public static ToDateTime ( DateTime value ) : DateTime
value DateTime
return DateTime
Beispiel #1
0
        public void Edit([FromBody] List <NhapHangEntity> entity)
        {
            var th = new List <NhapHang>();

            for (int i = 0; i < entity.Count - 1; i++)
            {
                var t = entity[i].MapTo <NhapHang>();
                //t.MaDonHang = entity[i].MaDonHang;
                t.IdNv    = IdCty();
                t.TenNcc  = entity[entity.Count - 1].TenNcc;
                t.TenNv   = _user.Users.SingleOrDefault(j => j.Id.Equals(_user.AbpSession.UserId)).FullName;
                t.NgayGhi = Convert.ToDateTime(entity[i].NgayGhi);
                th.Add(t);
            }

            //_nhap.CreatesOrUpdates(th);
            var t1 = entity[entity.Count - 1];

            if (t1 != null)
            {
                var h = _qlNx.GetAll(IdCty()).FirstOrDefault();
                if (h != null)
                {
                    h.IsActive = true;

                    h.ThanhTien = t1.SoLuong;
                    h.ThanhToan = t1.DonGiaMua;
                    h.Conlai    = (t1.SoLuong - t1.DonGiaMua);
                    _qlNx.Update(h);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Выполняет группировку элементов
        /// </summary>
        protected override void SetGroupsToItems()
        {
            itemsListView.Groups.Clear();

            if (OldColumnIndex != 9)
            {
                foreach (var item in ListViewItemList)
                {
                    var temp = ListViewGroupHelper.GetGroupString(item.Tag);

                    itemsListView.Groups.Add(temp, temp);
                    item.Group = itemsListView.Groups[temp];
                }
            }
            else
            {
                //Группировка элементов по датам выполнения
                var groupedItems = ListViewItemList.Where(lvi => lvi.Tag != null &&
                                                          lvi.Tag is NextPerformance)
                                   .GroupBy(lvi => Convert.ToDateTime(((NextPerformance)lvi.Tag).PerformanceDate).Date);
                foreach (var groupedItem in groupedItems)
                {
                    //Собрание всех выполнений на данную дату в одну коллекцию
                    var performances = groupedItem.Select(lvi => lvi.Tag as NextPerformance).ToList();

                    var temp = ListViewGroupHelper.GetGroupStringByPerformanceDate(performances, groupedItem.Key.Date);

                    itemsListView.Groups.Add(temp, temp);
                    foreach (var item in groupedItem)
                    {
                        item.Group = itemsListView.Groups[temp];
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Создает прогноз на заданную дату
        /// </summary>
        /// <param name="date">Дата, на которую необходимо построить отчет</param>
        /// <param name="baseComponentгрегат</param>
        /// <param name="current">Текущая наработка агрегата или налет ВС</param>
        /// <param name="lowerLimit">Нижняя граница прогноза</param>
        public ForecastData(DateTime date, BaseComponent baseComponent, Lifelength current, DateTime?lowerLimit = null)
        {
            BaseComponent        = baseComponent;
            SelectedForecastType = lowerLimit != null ? ForecastType.ForecastByPeriod : ForecastType.ForecastByDate;
            LowerLimit           = lowerLimit != null?Convert.ToDateTime(lowerLimit) : DateTimeExtend.GetCASMinDateTime();

            Init(date, BaseComponent.AverageUtilization, current);
        }
Beispiel #4
0
        protected virtual void AddForecastToDataSet(MaintenancePlanDataSet destinationDataSet)
        {
            ForecastData fd = _forecast != null?_forecast.GetForecastDataFrame() : null;

            if (fd == null)
            {
                destinationDataSet.ForecastTable.AddForecastTableRow(0,
                                                                     0,
                                                                     "",
                                                                     0,
                                                                     0,
                                                                     0,
                                                                     "");
                return;
            }
            double avgUtilizationCycles = fd.AverageUtilization.Cycles;
            double avgUtilizationHours  = fd.AverageUtilization.Hours;
            string avgUtilizationType   = fd.AverageUtilization.SelectedInterval.ToString();
            int    forecastCycles       = fd.ForecastLifelength.Cycles != null
                                                                         ? (int)fd.ForecastLifelength.Cycles
                                                                         : 0;
            int forecastHours = fd.ForecastLifelength.Hours != null
                                                                        ? (int)fd.ForecastLifelength.Hours
                                                                        : 0;
            int forecastDays = fd.ForecastLifelength.Days != null
                                                                   ? (int)fd.ForecastLifelength.Days
                                                                   : 0;
            string forecastDate = "";

            if (fd.SelectedForecastType == ForecastType.ForecastByDate)
            {
                forecastDate = SmartCore.Auxiliary.Convert.GetDateFormat(fd.ForecastDate);
            }
            else if (fd.SelectedForecastType == ForecastType.ForecastByPeriod)
            {
                forecastDate = SmartCore.Auxiliary.Convert.GetDateFormat(fd.LowerLimit) + " - " +
                               SmartCore.Auxiliary.Convert.GetDateFormat(fd.ForecastDate);
            }
            else if (fd.SelectedForecastType == ForecastType.ForecastByCheck)
            {
                if (fd.NextPerformanceByDate)
                {
                    forecastDate = fd.NextPerformanceString;
                }
                else
                {
                    forecastDate =
                        $"{fd.CheckName}. {SmartCore.Auxiliary.Convert.GetDateFormat(Convert.ToDateTime(fd.NextPerformance.PerformanceDate))}";
                }
            }
            destinationDataSet.ForecastTable.AddForecastTableRow(avgUtilizationCycles,
                                                                 avgUtilizationHours,
                                                                 avgUtilizationType,
                                                                 forecastCycles,
                                                                 forecastHours,
                                                                 forecastDays,
                                                                 forecastDate);
        }
        /// <summary>
        /// Converts a value to a <see cref="DateTime"/>.
        /// </summary>
        /// <param name="value">The object to convert.</param>
        /// <returns>The converted <paramref name="value"/>.</returns>
        public DateTime ToDateTime(object value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(SConvert.ToDateTime(value, CultureInfo.InvariantCulture));
        }
Beispiel #6
0
 private static object ConvertValue(string keyValue, string locale)
 {
     if (keyValue.StartsWith("I'"))
     {
         return(Convert.ToInt64(keyValue.Substring(2)));
     }
     if (keyValue.StartsWith("F'"))
     {
         return(Convert.ToDouble(keyValue.Substring(2)));
     }
     if (keyValue.StartsWith("D'"))
     {
         return(Convert.ToDateTime(keyValue.Substring(2), (locale == null ? CultureInfo.CurrentCulture : new CultureInfo(locale))));
     }
     return(keyValue.Replace("\\n", "\n").Replace("\\t", "\t"));
 }
        /// <summary>
        /// Добавление директив в таблицу данных
        /// </summary>
        /// <param name="dataset">Таблица, в которую добавляются данные</param>
        protected virtual void AddDirectivesToDataSet(MonthlyPlanDataSet dataset)
        {
            //Группировка элементов по датам выполнения
            IEnumerable <IGrouping <DateTime, NextPerformance> > groupedItems =
                _reportedDirectives.GroupBy(np => Convert.ToDateTime(np.PerformanceDate).Date)
                .OrderBy(g => g.Key);

            foreach (IGrouping <DateTime, NextPerformance> groupedItem in groupedItems)
            {
                DateTime dateTime   = groupedItem.Key.Date;
                string   dateString = groupedItem.Key.Date > DateTimeExtend.GetCASMinDateTime().Date
                    ? SmartCore.Auxiliary.Convert.GetDateFormat(groupedItem.Key.Date) + " "
                    : "";
                //группировка по родительскому самолету
                IEnumerable <IGrouping <string, NextPerformance> > groupByAircraft =
                    groupedItem.GroupBy(GetParent)
                    .OrderBy(g => g.Key.ToString());

                foreach (IGrouping <string, NextPerformance> byAircraft in groupByAircraft)
                {
                    //Формирование первой части названия группы, состоящей из даты выполнения
                    string temp = "";
                    //Собрание всех выполнений на данную дату в одну коллекцию
                    IEnumerable <NextPerformance> performances = byAircraft.Select(lvi => lvi);
                    //Добавление в название присутствующих на данную дату чеков программы обслуживания
                    IEnumerable <NextPerformance> maintenanceCheckPerformances =
                        performances.Where(np => np.Parent != null && np.Parent is MaintenanceCheck);
                    foreach (NextPerformance maintenanceCheckPerformance in maintenanceCheckPerformances)
                    {
                        if (maintenanceCheckPerformance is MaintenanceNextPerformance)
                        {
                            MaintenanceNextPerformance mnp = maintenanceCheckPerformance as MaintenanceNextPerformance;
                            temp += mnp.PerformanceGroup.GetGroupName();
                        }
                        else
                        {
                            temp += ((MaintenanceCheck)maintenanceCheckPerformance.Parent).Name;
                        }
                        temp += " ";
                    }

                    //Добавление в название присутствующих на данную дату директив летной годности
                    IEnumerable <NextPerformance> adPerformances =
                        performances.Where(np => np.Parent != null && np.Parent is Directive);
                    if (adPerformances.Count() > 0)
                    {
                        temp += "AD ";
                    }

                    //Добавление в название присутствующих на данную дату компонентов или задач по ним
                    IEnumerable <NextPerformance> componentPerformances =
                        performances.Where(np => np.Parent != null && (np.Parent is Component || np.Parent is ComponentDirective));
                    if (componentPerformances.Count() > 0)
                    {
                        temp += "Comp ";
                    }

                    //Добавление в название присутствующих на данную дату MPD
                    IEnumerable <NextPerformance> mpdPerformances =
                        performances.Where(np => np.Parent != null && np.Parent is MaintenanceDirective);
                    if (maintenanceCheckPerformances.Count() == 0 && mpdPerformances.Count() > 0)
                    {
                        temp += "MPD ";
                    }

                    string destinationString = byAircraft.Key;


                    dataset.ItemsTable.AddItemsTableRow(dateString, destinationString, temp, dateTime.Ticks, destinationString);
                }
            }
        }
        protected override List <CustomCell> GetListViewSubItems(MaintenanceDirective item)
        {
            var subItems = new List <CustomCell>();

            //////////////////////////////////////////////////////////////////////////////////////
            //         Определение последнего выполнения директивы и KitRequiered               //
            //////////////////////////////////////////////////////////////////////////////////////
            var defaultDateTime          = DateTimeExtend.GetCASMinDateTime();
            var lastComplianceDate       = defaultDateTime;
            var nextComplianceDate       = defaultDateTime;
            var lastComplianceLifeLength = Lifelength.Zero;
            //Lifelength nextComplianceLifelength = Lifelength.Null;

            string lastPerformanceString, firstPerformanceString = "N/A";

            var tcnColor = radGridView1.ForeColor;
            var kitColor = radGridView1.BackColor;
            var ata      = item.ATAChapter;

            if (item.LastPerformance != null)
            {
                lastComplianceDate       = item.LastPerformance.RecordDate;
                lastComplianceLifeLength = item.LastPerformance.OnLifelength;
            }
            if (item.Threshold.FirstPerformanceSinceNew != null && !item.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
            {
                firstPerformanceString = "s/n: " + item.Threshold.FirstPerformanceSinceNew;
            }
            if (item.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                !item.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
            {
                if (firstPerformanceString != "N/A")
                {
                    firstPerformanceString += " or ";
                }
                else
                {
                    firstPerformanceString = "";
                }
                firstPerformanceString += "s/e.d: " + item.Threshold.FirstPerformanceSinceEffectiveDate;
            }

            if (item.NextPerformanceDate != null && item.NextPerformanceDate > defaultDateTime)
            {
                nextComplianceDate = Convert.ToDateTime(item.NextPerformanceDate);
            }

            var author              = GlobalObjects.CasEnvironment.GetCorrector(item);
            var kitRequieredString  = item.KitsApplicable ? item.Kits.Count + " EA" : "N/A";
            var ndtString           = item.NDTType.ShortName;
            var skillString         = item.Skill.ShortName;
            var categoryString      = item.Category.ShortName;
            var remarksString       = item.Remarks;
            var hiddenRemarksString = item.HiddenRemarks;

            if (lastComplianceDate <= defaultDateTime)
            {
                lastPerformanceString = "N/A";
            }
            else
            {
                lastPerformanceString = lastComplianceLifeLength.ToString();
            }

            var lastDate = (lastComplianceDate <= defaultDateTime)
                                ? ""
                                : SmartCore.Auxiliary.Convert.GetDateFormat(lastComplianceDate);

            var repeat = item.Threshold.RepeatInterval.ToString();

            if (item.APUCalc)
            {
                firstPerformanceString = firstPerformanceString.Replace("FH", "AH");
                repeat = repeat.Replace("FH", "AH");
            }

            //////////////////////////////////////////////////////////////////////////////////////
            var description = item.Description != "" ? item.Description : "N/A";
            var app         = item.IsApplicability ? $"APL {item.Applicability}" : $"N/A {item.Applicability}";
            var taskNumber  = item.MPDTaskNumber != "" ? item.MPDTaskNumber : "N/A";
            var taskCheck   = item.TaskNumberCheck != "" ? item.TaskNumberCheck : "N/A";
            var maintManual = item.MaintenanceManual != "" ? item.MaintenanceManual : "N/A";
            var mrb         = item.MRB != "" ? item.MRB : "N/A";
            var check       = item.MaintenanceCheck != null ? item.MaintenanceCheck.Name : "N/A";
            var status      = item.Status;
            var condition   = !string.IsNullOrEmpty(firstPerformanceString) ? (item.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                ? "/WF"
                                : "/WL") : "";
            var conditionRepeat = !item.Threshold.RepeatInterval.IsNullOrZero() ? (item.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst
                                ? "/WF"
                                : "/WL") : "";

            if (item.TaskCardNumberFile == null)
            {
                tcnColor = Color.MediumVioletRed;
            }

            if (item.KitsApplicable && item.Kits.Count == 0)
            {
                kitColor = Color.FromArgb(Highlight.Red.Color);
            }

            subItems.Add(CreateRow(item.ScheduleItem, item.ScheduleItem));
            subItems.Add(CreateRow(taskCheck, taskCheck));
            subItems.Add(CreateRow(item.TaskCardNumber, item.TaskCardNumber, tcnColor));
            subItems.Add(CreateRow(description, description));
            subItems.Add(CreateRow(item.Program.ToString(), item.Program));
            subItems.Add(CreateRow(item.ProgramIndicator.ShortName, item.ProgramIndicator));
            subItems.Add(CreateRow(item.WorkType.ToString(), item.WorkType));
            subItems.Add(CreateRow(check, check));
            subItems.Add(CreateRow(item.APUCalc ? "Yes" : "No", item.APUCalc));
            subItems.Add(CreateRow($"{firstPerformanceString} {condition}", firstPerformanceString));
            subItems.Add(CreateRow($"{repeat} {conditionRepeat}", item.Threshold.RepeatInterval));
            subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(item.NextPerformance?.PerformanceDate), item.NextPerformance?.PerformanceDate));
            subItems.Add(CreateRow(item.NextPerformance?.PerformanceSource.ToString(), item.NextPerformance?.PerformanceSource));
            subItems.Add(CreateRow(item.NextPerformance?.Remains.ToString(), item.NextPerformance?.Remains));
            subItems.Add(CreateRow(item.NextPerformance?.NextLimit.Days != null ? SmartCore.Auxiliary.Convert.GetDateFormat(item.NextPerformance?.NextPerformanceDateNew) : "", item.NextPerformance?.NextPerformanceDateNew));
            subItems.Add(CreateRow(item.NextPerformance?.NextLimit.ToString(), item.NextPerformance?.NextLimit.ToString()));
            subItems.Add(CreateRow(item.NextPerformance?.RemainLimit.ToString(), item.NextPerformance?.RemainLimit.ToString()));
            subItems.Add(CreateRow(lastDate, lastComplianceDate));
            subItems.Add(CreateRow(lastPerformanceString, lastComplianceDate));
            subItems.Add(CreateRow(item.Zone, item.Zone));
            subItems.Add(CreateRow(item.Workarea, item.Workarea));
            subItems.Add(CreateRow(item.Access, item.Access));
            subItems.Add(CreateRow(status.ToString(), status));
            subItems.Add(CreateRow(taskNumber, taskNumber));
            subItems.Add(CreateRow(maintManual, maintManual));
            subItems.Add(CreateRow(mrb, mrb));
            subItems.Add(CreateRow(item.TaskCardNumber, item.TaskCardNumber));
            subItems.Add(CreateRow(item.CriticalSystem.ToString(), item.CriticalSystem));
            subItems.Add(CreateRow(ata.ToString(), ata));
            subItems.Add(CreateRow(kitRequieredString, kitRequieredString, kitColor));
            subItems.Add(CreateRow(ndtString, ndtString));
            subItems.Add(CreateRow(skillString, skillString));
            subItems.Add(CreateRow(categoryString, categoryString));
            subItems.Add(CreateRow(item.Elapsed <= 0 ? "" : item.Elapsed.ToString(), item.Elapsed));
            subItems.Add(CreateRow(item.ManHours <= 0 ? "" : item.ManHours.ToString(), item.ManHours));
            subItems.Add(CreateRow(item.Cost <= 0 ? "" : item.Cost.ToString(), item.Cost));
            subItems.Add(CreateRow(app, app));
            subItems.Add(CreateRow(remarksString, remarksString));
            subItems.Add(CreateRow(hiddenRemarksString, hiddenRemarksString));
            subItems.Add(CreateRow(author, author));

            return(subItems);
        }
Beispiel #9
0
		DateTime IConvertible.ToDateTime (IFormatProvider provider)
		{
			return Convert.ToDateTime (Value, provider);
		}
Beispiel #10
0
        /// <summary>
        ///
        /// </summary>
        //protected override void SetGroupsToItems(int columnIndex)
        //{
        //}
        #endregion

        #region protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(Procedure item)
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        protected override List <CustomCell> GetListViewSubItems(Procedure item)
        {
            var subItems = new List <CustomCell>();

            //////////////////////////////////////////////////////////////////////////////////////
            //         Определение последнего выполнения директивы и KitRequiered               //
            //////////////////////////////////////////////////////////////////////////////////////
            DateTime   defaultDateTime          = DateTimeExtend.GetCASMinDateTime();
            DateTime   lastComplianceDate       = defaultDateTime;
            DateTime   nextComplianceDate       = defaultDateTime;
            Lifelength lastComplianceLifeLength = Lifelength.Zero;

            string lastPerformanceString, firstPerformanceString = "N/A";

            if (item.LastPerformance != null)
            {
                lastComplianceDate       = item.LastPerformance.RecordDate;
                lastComplianceLifeLength = item.LastPerformance.OnLifelength;
            }
            if (item.Threshold.FirstPerformanceSinceNew != null && !item.Threshold.FirstPerformanceSinceNew.IsNullOrZero())
            {
                firstPerformanceString = "s/n: " + item.Threshold.FirstPerformanceSinceNew;
            }
            if (item.Threshold.FirstPerformanceSinceEffectiveDate != null &&
                !item.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero())
            {
                if (firstPerformanceString != "N/A")
                {
                    firstPerformanceString += " or ";
                }
                else
                {
                    firstPerformanceString = "";
                }
                firstPerformanceString += "s/e.d: " + item.Threshold.FirstPerformanceSinceEffectiveDate;
            }

            //if (item.BindDetailDirectives.Count == 0)
            //{
            if (item.NextPerformanceDate != null && item.NextPerformanceDate > defaultDateTime)
            {
                nextComplianceDate = Convert.ToDateTime(item.NextPerformanceDate);
            }
            //    nextComplianceLifelength = item.NextCompliance;
            //}
            //else
            //{
            //    DetailDirective firstLimitter =
            //            item.BindDetailDirectives.Where(bdd => bdd.NextComplianceDate != null &&
            //                                                   bdd.NextComplianceDate > defaultDateTime)
            //                                     .OrderBy(d => d)
            //                                     .FirstOrDefault();
            //    if (firstLimitter != null)
            //    {
            //        nextComplianceDate = Convert.ToDateTime(firstLimitter.NextComplianceDate);
            //        nextComplianceLifelength = firstLimitter.NextCompliance;
            //    }
            //}

            string kitRequieredString  = item.Kits.Count + " kits";
            string remarksString       = item.Remarks;
            string hiddenRemarksString = item.HiddenRemarks;

            if (lastComplianceDate <= defaultDateTime)
            {
                lastPerformanceString = "N/A";
            }
            else
            {
                lastPerformanceString = SmartCore.Auxiliary.Convert.GetDateFormat(lastComplianceDate) + " " +
                                        lastComplianceLifeLength;
            }
            string nextComplianceString = ((nextComplianceDate <= defaultDateTime)
                                                                                           ? ""
                                                                                           : SmartCore.Auxiliary.Convert.GetDateFormat(nextComplianceDate) + " ") +
                                          item.NextPerformanceSource;
            string nextRemainString = item.Remains != null && !item.Remains.IsNullOrZero()
                                                                                  ? item.Remains.ToString()
                                                                                  : "N/A";

            //////////////////////////////////////////////////////////////////////////////////////

            var             author           = GlobalObjects.CasEnvironment.GetCorrector(item);
            string          description      = item.Description != "" ? item.Description : "N/A";
            string          title            = item.Title != "" ? item.Title : "N/A";
            string          reqiredDocuments = item.DocumentReferences.Count > 0 ? item.DocumentReferences.Aggregate("", (current, i) => current + (i.Document + "; ")): "N/A";
            DirectiveStatus status           = item.Status;

            subItems.Add(CreateRow(title, title));
            subItems.Add(CreateRow(description, description));
            subItems.Add(CreateRow(item.ProcedureRating.ToString(), item.ProcedureRating));
            subItems.Add(CreateRow(item.Level.ToString(), item.Level));
            subItems.Add(CreateRow(item.AuditedObject, item.AuditedObject));
            subItems.Add(CreateRow(item.ProcedureType.ToString(), item.ProcedureType));
            subItems.Add(CreateRow(firstPerformanceString, firstPerformanceString));
            subItems.Add(CreateRow(item.Threshold.RepeatInterval.ToString(), item.Threshold.RepeatInterval));
            subItems.Add(CreateRow(nextComplianceString, nextComplianceDate));
            subItems.Add(CreateRow(nextRemainString, nextRemainString));
            subItems.Add(CreateRow(lastPerformanceString, lastComplianceDate));
            subItems.Add(CreateRow(status.ToString(), status));
            subItems.Add(CreateRow(reqiredDocuments, reqiredDocuments));
            subItems.Add(CreateRow(kitRequieredString, kitRequieredString));
            subItems.Add(CreateRow(item.ManHours <= 0 ? "" : item.ManHours.ToString(), item.ManHours));
            subItems.Add(CreateRow(item.Cost <= 0 ? "" : item.Cost.ToString(), item.Cost));
            subItems.Add(CreateRow(remarksString, remarksString));
            subItems.Add(CreateRow(hiddenRemarksString, hiddenRemarksString));
            subItems.Add(CreateRow(author, author));

            return(subItems);
        }
        private ListViewItem GetListViewItem(MaintenanceCheckRecordGroup grouping)
        {
            string name              = "N/A";
            string type              = "N/A";
            string resource          = "N/A";
            string group             = "N/A";
            string num               = "N/A";
            string recordDate        = "N/A";
            string performanceSource = "N/A";
            string remarksString     = "N/A";
            Color  backColor         = Color.White;

            if (grouping.Records.Count > 0)
            {
                grouping.Sort();

                MaintenanceCheckRecord mcr = grouping.LastOrDefault();
                MaintenanceCheck       mc  = grouping.GetMaxIntervalCheck();

                type      = mc.Schedule ? " (Schedule) " : " (Store) ";
                resource  = mc.Resource.ToString();
                group     = mc.Grouping ? " (Group)" : "";
                backColor = mc.Schedule ? Color.White : Color.Gainsboro;

                if (mcr != null)
                {
                    num  = mc.Grouping ? mcr.NumGroup.ToString() : "N/A";
                    name = _currentAircraft != null && _currentAircraft.MaintenanceProgramCheckNaming
                                        ? (!string.IsNullOrEmpty(grouping.First().ComplianceCheckName)
                                               ? mcr.ComplianceCheckName
                                               : mc.Name)
                                        : mc.Name;
                    recordDate        = UsefulMethods.NormalizeDate(mcr.RecordDate);
                    performanceSource = mcr.OnLifelength.ToRepeatIntervalsFormat();
                    remarksString     = mcr.Remarks;

                    if (mc.Grouping)
                    {
                        MaintenanceProgramChangeRecord mpcr = mc.ParentAircraft != null
                            ? mc.ParentAircraft.MaintenanceProgramChangeRecords.
                                                              GetLastKnownRecord(Convert.ToDateTime(mcr.RecordDate))
                            : null;

                        if (mpcr == null || mpcr.MSG < MSG.MSG3)
                        {
                            var complianceItems = from compliance in grouping
                                                  orderby compliance.OnLifelength.Hours descending
                                                  select compliance;
                            name += " (" + complianceItems.Aggregate("", (current, compliance) => current + (compliance.ParentCheck.Name + " ")) + ")";
                        }
                    }
                }
            }

            ListViewItem listViewItem = new ListViewItem(num + type + resource + group)
            {
                Tag       = grouping.ToList(),
                Group     = listViewCompliance.Groups["last"],
                BackColor = backColor
            };

            listViewItem.SubItems.Add(name);
            listViewItem.SubItems.Add(recordDate);
            listViewItem.SubItems.Add(performanceSource);
            listViewItem.SubItems.Add(remarksString);
            return(listViewItem);
        }
Beispiel #12
0
        public string AddPatient(int facilityId, int entryPointId, string enrollmentDate, string personDateOfBirth, string nationalId, int patientType, string dobPrecision, string identifiersList)
        {
            ExMessage message = new ExMessage();

            try
            {
                PersonId = int.Parse(Session["PersonId"].ToString());
                int userId = Convert.ToInt32(Session["AppUserId"]);

                var patientManager             = new PatientManager();
                var patientMasterVisitManager  = new PatientMasterVisitManager();
                var patientEnrollmentManager   = new PatientEnrollmentManager();
                var patientIdentifierManager   = new PatientIdentifierManager();
                var patientEntryPointManager   = new PatientEntryPointManager();
                var patientLookUpManager       = new PatientLookupManager();
                var mstPatientLogic            = new MstPatientLogic();
                var personContactLookUpManager = new PersonContactLookUpManager();
                var personContacts             = new List <PersonContactLookUp>();
                var personLookUp = new PersonLookUpManager();
                var lookupLogic  = new LookupLogic();

                //var identifiersObjects = JsonConvert.DeserializeObject<Dictionary<int, string>>(identifiersList);
                var           identifiersObjects = new JavaScriptSerializer().Deserialize <Dictionary <string, string> >(identifiersList);
                String        sDate            = DateTime.Now.ToString();
                DateTime      datevalue        = Convert.ToDateTime(sDate);
                PatientLookup isPersonEnrolled = patientLookUpManager.GetPatientByPersonId(PersonId);
                dobPrecision = String.IsNullOrWhiteSpace(dobPrecision) ? "false" : "true";

                foreach (var item in identifiersObjects)
                {
                    var identifiers = patientIdentifierManager.CheckIfIdentifierNumberIsUsed(item.Value, Convert.ToInt32(item.Key));
                    if (identifiers.Count > 0)
                    {
                        foreach (var items in identifiers)
                        {
                            if (isPersonEnrolled != null)
                            {
                                if (items.PatientId == isPersonEnrolled.Id)
                                {
                                }
                                else
                                {
                                    var exception = new SoapException("No: " + item.Value + " already exists", SoapException.ClientFaultCode);
                                    throw exception;
                                }
                            }
                            else
                            {
                                var exception = new SoapException("No: " + item.Value + " already exists", SoapException.ClientFaultCode);
                                throw exception;
                            }
                        }
                    }
                }

                if (isPersonEnrolled != null)
                {
                    List <PatientRegistrationLookup> patientsByPersonId = patientManager.GetPatientIdByPersonId(PersonId);
                    var           patientIndex = datevalue.Year.ToString() + '-' + PersonId;
                    PatientEntity patient      = new PatientEntity();
                    if (patientsByPersonId.Count > 0)
                    {
                        patient.FacilityId  = facilityId;
                        patient.DateOfBirth = DateTime.Parse(personDateOfBirth);
                        patient.NationalId  = nationalId;
                        patient.ptn_pk      = patientsByPersonId[0].ptn_pk > 0 ? patientsByPersonId[0].ptn_pk : 0;

                        patientManager.UpdatePatient(patient, patientsByPersonId[0].Id);
                        patientId = patientsByPersonId[0].Id;
                    }
                    else
                    {
                        patient.PersonId     = PersonId;
                        patient.ptn_pk       = 0;
                        patient.FacilityId   = facilityId;
                        patient.PatientType  = patientType;
                        patient.PatientIndex = patientIndex;
                        patient.DateOfBirth  = DateTime.Parse(personDateOfBirth);
                        patient.NationalId   = (nationalId);
                        patient.Active       = true;
                        patient.CreatedBy    = userId;
                        patient.CreateDate   = DateTime.Now;
                        patient.DeleteFlag   = false;
                        patient.DobPrecision = bool.Parse(dobPrecision);

                        patientId = patientManager.AddPatient(patient);
                    }
                    Session["PatientPK"] = patientId;

                    if (patientId > 0)
                    {
                        var visitTypes = lookupLogic.GetItemIdByGroupAndItemName("VisitType", "Enrollment");
                        var visitType  = 0;
                        if (visitTypes.Count > 0)
                        {
                            visitType = visitTypes[0].ItemId;
                        }

                        //Add enrollment visit
                        patientMasterVisitId =
                            patientMasterVisitManager.AddPatientMasterVisit(patientId, userId, visitType);
                        //Enroll Patient to service
                        patientEnrollmentId = patientEnrollmentManager.addPatientEnrollment(patientId, enrollmentDate, userId);
                        //Add enrollment entry point
                        patientEntryPointId = patientEntryPointManager.addPatientEntryPoint(patientId, entryPointId, userId);

                        //Get User Details to be used in BLUE CARD
                        var patient_person_details = personLookUp.GetPersonById(PersonId);
                        var greencardlookup        = new PersonGreenCardLookupManager();
                        var greencardptnpk         = greencardlookup.GetPtnPkByPersonId(PersonId);

                        if (patient_person_details != null)
                        {
                            var maritalStatus =
                                new PersonMaritalStatusManager().GetCurrentPatientMaritalStatus(PersonId);
                            personContacts = personContactLookUpManager.GetPersonContactByPersonId(PersonId);
                            var address  = "";
                            var phone    = "";
                            var facility = lookupLogic.GetFacility();

                            if (personContacts.Count > 0)
                            {
                                address = personContacts[0].PhysicalAddress;
                                phone   = personContacts[0].MobileNumber;
                            }

                            var MaritalStatusId = 0;
                            if (maritalStatus != null)
                            {
                                MaritalStatusId = maritalStatus.MaritalStatusId;
                            }

                            var sex = 0;
                            var enrollmentBlueCardId = "";

                            if (LookupLogic.GetLookupNameById(patient_person_details.Sex) == "Male")
                            {
                                sex = 16;
                            }
                            else if (LookupLogic.GetLookupNameById(patient_person_details.Sex) == "Female")
                            {
                                sex = 17;
                            }

                            foreach (var item in identifiersObjects)
                            {
                                if (Convert.ToInt32(item.Key) == 1)
                                {
                                    enrollmentBlueCardId = item.Value;
                                }
                            }


                            if (greencardptnpk.Count == 0)
                            {
                                ptn_Pk = mstPatientLogic.InsertMstPatient(
                                    (patient_person_details.FirstName),
                                    (patient_person_details.LastName),
                                    (patient_person_details.MiddleName),
                                    facility.FacilityID, enrollmentBlueCardId, entryPointId,
                                    DateTime.Parse(enrollmentDate), sex,
                                    DateTime.Parse(personDateOfBirth),
                                    1, MaritalStatusId,
                                    address, phone, userId, Session["AppPosID"].ToString(),
                                    203, DateTime.Parse(enrollmentDate), DateTime.Now);

                                patient.ptn_pk = ptn_Pk;
                                patientManager.UpdatePatient(patient, patientId);
                            }
                            else
                            {
                                ptn_Pk         = greencardptnpk[0].Ptn_Pk;
                                patient.ptn_pk = greencardptnpk[0].Ptn_Pk;
                                patientManager.UpdatePatient(patient, patientId);
                            }
                        }

                        Session["PatientMasterVisitId"] = patientMasterVisitId;

                        if (patientMasterVisitId > 0)
                        {
                            foreach (var item in identifiersObjects)
                            {
                                patientIdentifierId = patientIdentifierManager.addPatientIdentifier(patientId,
                                                                                                    patientEnrollmentId, Convert.ToInt32(item.Key), item.Value, facilityId);

                                var identifierManager = new IdentifierManager();
                                var identifierList    = identifierManager.GetIdentifiersById(Convert.ToInt32(item.Key));
                                var hivtesting        = _hivTestingManager.GetAll().OrderByDescending(y => y.Id).FirstOrDefault(n => n.PersonId == PersonId);
                                if (identifierList.Count > 0)
                                {
                                    if (identifierList[0].Code == "CCCNumber")
                                    {
                                        if (hivtesting != null)
                                        {
                                            hivtesting.ReferredToCare = true;
                                            _hivTestingManager.UpdatePatientHivTesting(hivtesting);

                                            PatientLinkage patLinkage = new PatientLinkage();
                                            patLinkage.LinkageDate = DateTime.Parse(enrollmentDate);
                                            patLinkage.CCCNumber   = item.Value;
                                            patLinkage.PersonId    = PersonId;
                                            patLinkage.CreatedBy   = userId;
                                            patLinkage.Enrolled    = true;
                                            patLinkage.PatientId   = patientId;

                                            linkageManager.AddPatientLinkage(patLinkage);
                                        }
                                    }
                                }
                            }

                            if (greencardptnpk.Count == 0)
                            {
                                mstPatientLogic.AddOrdVisit(ptn_Pk, facilityId, DateTime.Now, 110,
                                                            userId, DateTime.Now, 203);
                            }


                            message.errorcode = 0;
                            message.msg      += "<p>Successfully enrolled patient.</p>";
                        }
                    }
                }
                else
                {
                    var                  patientLookManager = new PatientLookupManager();
                    PatientLookup        patient            = patientLookManager.GetPatientByPersonId(PersonId);
                    List <PatientLookup> pk = new List <PatientLookup>();
                    pk.Add(patient);
                    if (patient != null)
                    {
                        Session["PatientPK"] = patient.Id;

                        List <PatientEntity> listPatient = new List <PatientEntity>();
                        var entity = pk.ConvertAll(x => new PatientEntity {
                            Id         = x.Id, Active = x.Active, DateOfBirth = x.DateOfBirth,
                            ptn_pk     = x.ptn_pk, PatientType = x.PatientType, PatientIndex = x.PatientIndex, NationalId = x.NationalId,
                            FacilityId = x.FacilityId
                        });

                        var patientAuditData = AuditDataUtility.Serializer(entity);

                        PatientEntity updatePatient = new PatientEntity();
                        updatePatient.ptn_pk      = patient.ptn_pk;
                        updatePatient.DateOfBirth = patient.DateOfBirth;
                        updatePatient.NationalId  = nationalId;
                        updatePatient.FacilityId  = patient.FacilityId;


                        //listPatient.Add(entity);
                        updatePatient.AuditData = patientAuditData;
                        //var enrollmentAuditData = AuditDataUtility.Serializer(patient);

                        patientManager.UpdatePatient(updatePatient, patient.Id);

                        int patientMasterVisitId = patientMasterVisitManager.PatientMasterVisitCheckin(patient.Id, userId);
                        Session["PatientMasterVisitId"] = patientMasterVisitId;

                        List <PatientEntryPoint> entryPoints = patientEntryPointManager.GetPatientEntryPoints(patient.Id);

                        if (entryPoints.Count > 0)
                        {
                            var entryPointAuditData = AuditDataUtility.Serializer(entryPoints);

                            entryPoints[0].EntryPointId = entryPointId;
                            entryPoints[0].AuditData    = entryPointAuditData;

                            patientEntryPointManager.UpdatePatientEntryPoint(entryPoints[0]);
                        }
                        foreach (var item in identifiersObjects)
                        {
                            var identifiersByPatientId = patientIdentifierManager
                                                         .GetPatientEntityIdentifiersByPatientId(patient.Id, Convert.ToInt32(item.Key));

                            if (identifiersByPatientId.Count > 0)
                            {
                                foreach (var entityIdentifier in identifiersByPatientId)
                                {
                                    int enrollmentId = entityIdentifier.PatientEnrollmentId;

                                    PatientEntityEnrollment entityEnrollment =
                                        patientEnrollmentManager.GetPatientEntityEnrollment(enrollmentId);
                                    List <PatientEntityEnrollment> listEnrollment = new List <PatientEntityEnrollment>();
                                    listEnrollment.Add(entityEnrollment);
                                    var enrollmentAuditData = AuditDataUtility.Serializer(listEnrollment);

                                    entityEnrollment.EnrollmentDate = DateTime.Parse(enrollmentDate);
                                    entityEnrollment.AuditData      = enrollmentAuditData;

                                    patientEnrollmentManager.updatePatientEnrollment(entityEnrollment);

                                    var entityIdentifierAuditData = AuditDataUtility.Serializer(identifiersByPatientId);
                                    entityIdentifier.IdentifierValue = item.Value;
                                    entityIdentifier.AuditData       = entityIdentifierAuditData;
                                    patientIdentifierManager.UpdatePatientIdentifier(entityIdentifier, facilityId);
                                }
                            }
                            else
                            {
                                patientEnrollmentId = patientEnrollmentManager.addPatientEnrollment(patient.Id, enrollmentDate, userId);
                                patientEntryPointId = patientEntryPointManager.addPatientEntryPoint(patient.Id, entryPointId, userId);
                                patientIdentifierId = patientIdentifierManager.addPatientIdentifier(patient.Id,
                                                                                                    patientEnrollmentId, Convert.ToInt32(item.Key), item.Value, facilityId);
                            }
                        }
                    }
                }
            }
            catch (SoapException ex)
            {
                message.errorcode = 1;
                message.msg       = ex.Message;
            }

            return(Msg = new JavaScriptSerializer().Serialize(message));
        }
Beispiel #13
0
 public DateTime ToDateTime(object value)
     => SystemConvert.ToDateTime(value);
Beispiel #14
0
        /// <summary>
        /// Convert REST Product List to DB products
        /// </summary>
        /// <param name="products"></param>
        /// <returns></returns>
        private static List <products> GetProducts(List <Product> products)
        {
            List <products> dbProducts = new List <products>();

            foreach (var product in products)
            {
                DateTime upd_dt;
                if (!DateTime.TryParse(product.LastUpdate.ToString(), out upd_dt))
                {
                    upd_dt = DateTime.Now;
                }

                /** Sam changed July 2018 - to get Categories - only the last level */
                string thisCategory = null;
                if (product.CategoryList.Count > 0)
                {
                    thisCategory = product.CategoryList[0].CategoryName;
                    foreach (var cat in product.CategoryList)
                    {
                        if (cat.CategoryName == "_Test_Hidden")
                        {
                            thisCategory = "_Test_Hidden";
                            break;
                        }
                    }
                }


                dbProducts.Add(new products
                {
                    SKU         = product.SKUInfo.SKU,
                    catalogid   = Convert.ToInt32(product.SKUInfo.CatalogID),
                    mfgid       = product.MFGID,
                    accessgroup = product.AllowAccessCustomerGroupName,
                    //accessories =  null,
                    listing_displaytype = null,
                    //backorder_message = product.BackOrderMessage,
                    categoriesaaa   = thisCategory,
                    categoryspecial = product.CategorySpecial,//changed int to boolean
                    cost            = product.SKUInfo.Cost,
                    date_created    = Convert.ToDateTime(product.DateCreated).ToString("yyyy-MM-ddTHH:mm:ss"),
                    depth           = product.Depth,//changed int to double
                    description     = product.ShortDescription,
                    displaytext     = product.DisplayText,
                    //display_stock = product.OutOfStockMessage,
                    //distributor = product.DistributorList != null && product.DistributorList.Count > 0 ? product.DistributorList[0].DistributorName : string.Empty,
                    //eproduct_expire = null,
                    //eproduct_instructions = product.SpecialInstructions,
                    //eproduct_password = null,
                    //eproduct_path = null,
                    //eproduct_random = null,
                    //eproduct_reuseserial = product.SerialList != null && product.SerialList.Count > 0? product.SerialList[0].SerialUses.ToString(): string.Empty,
                    //eproduct_serial = product.SerialList != null && product.SerialList.Count > 0 ? product.SerialList[0].SerialCode : string.Empty,
                    extended_description = product.Description,
                    extra_field_1        = product.ExtraField1,
                    extra_field_10       = product.ExtraField10,
                    extra_field_11       = product.ExtraField11,
                    extra_field_12       = product.ExtraField12,
                    extra_field_13       = product.ExtraField13,
                    extra_field_2        = product.ExtraField2,
                    extra_field_3        = product.ExtraField3,
                    extra_field_4        = product.ExtraField4,
                    extra_field_5        = product.ExtraField5,
                    extra_field_6        = product.ExtraField6,
                    extra_field_7        = product.ExtraField7,
                    extra_field_8        = product.ExtraField8,
                    extra_field_9        = product.ExtraField9,
                    filename             = product.CustomFileName,
                    //fractional_qty = null,//product.AllowFractionalQuantity
                    free_shipping = product.FreeShipping,//change to bit
                    //giftcertificate = product.GiftCertificate,//changed to bit
                    gtin        = product.GTIN,
                    height      = Convert.ToInt32(product.Height), //not changed
                    hide        = product.Hide,                    //changed to bit
                    hide_1      = product.PriceLevel1Hide,
                    hide_10     = product.PriceLevel10Hide,
                    hide_2      = product.PriceLevel2Hide,
                    hide_3      = product.PriceLevel3Hide,
                    hide_4      = product.PriceLevel4Hide,
                    hide_5      = product.PriceLevel5Hide,
                    hide_6      = product.PriceLevel6Hide,
                    hide_7      = product.PriceLevel7Hide,
                    hide_8      = product.PriceLevel8Hide,
                    hide_9      = product.PriceLevel9Hide,
                    homespecial = product.HomeSpecial,
                    //change all
                    image1        = product.MainImageFile,
                    image2        = product.AdditionalImageFile2,
                    image3        = product.AdditionalImageFile3,
                    image4        = product.AdditionalImageFile4,
                    imagecaption1 = product.MainImageCaption,
                    imagecaption2 = product.AdditionalImageCaption2,
                    imagecaption3 = product.AdditionalImageCaption3,
                    imagecaption4 = product.AdditionalImageCaption4,
                    //instock_message = product.InStockMessage,
                    keywords     = product.Keywords,
                    last_update  = upd_dt.ToString("yyyy-MM-ddTHH:mm:ss"), // product.LastUpdate.ToString(),
                    loginlevel   = product.LoginRequiredOptionID,
                    manufacturer = product.ManufacturerID.ToString(),
                    maximumorder = product.MaximumQuantity.ToString(),
                    metatags     = product.MetaTags,
                    minimumorder = product.MinimumQuantity.ToString(),
                    //minorderpkg = null,
                    name          = null,
                    nonsearchable = product.NonSearchable, //changed to bit
                    nontax        = product.NonTaxable,    //changed to bit
                    notforsale    = product.NotForSale,    //changed to bit
                    onsale        = product.StockAlert,
                    //outofstock_message = product.OutOfStockMessage,
                    price            = product.SKUInfo.Price,
                    price2           = product.PriceLevel2,
                    price3           = product.PriceLevel3,
                    price_1          = product.PriceLevel1,
                    price_10         = product.PriceLevel10,
                    price_2          = product.PriceLevel2,
                    price_3          = product.PriceLevel3,
                    price_4          = product.PriceLevel4,
                    price_5          = product.PriceLevel5,
                    price_6          = product.PriceLevel6,
                    price_7          = product.PriceLevel7,
                    price_8          = product.PriceLevel8,
                    price_9          = product.PriceLevel9,
                    pricing_groupopt = product.GroupOptionsForQuantityPricing,
                    //qtydiscount_opt = product.GroupOptionsForQuantityPricing,
                    //qtyoptions = product.QuantityOptions,
                    //realmedia = product.MediaFile,
                    //recurring_order = null,
                    //redirectto = product.LoginRequiredOptionRedirectTo,
                    //related = product.RelatedProductList != null && product.RelatedProductList.Count > 0 ? product.RelatedProductList[0].RelatedProductID.ToString() : null,
                    //reminders_enabled = null,
                    //reminders_frequency = null,
                    //review_average = null,
                    //review_count = null,
                    //reward_disable = product.DisableRewards.HasValue && product.DisableRewards.Value ? 1: 0,
                    //reward_points = product.RewardPoints,
                    //reward_redeem = product.RedeemPoints,
                    //rma_maxperiod = product.RMAMaxPeriod,
                    saleprice = null,
                    //self_ship = product.SelfShip.HasValue && product.SelfShip.Value ? 1: 0,
                    shipcost = product.ShipCost,
                    //show_out_stock = null,
                    sorting     = null,
                    stock       = product.StockAlert,
                    stock_alert = product.StockAlert.ToString(),
                    //tax_code = product.TaxCode,
                    thumbnail = product.ThumbnailFile,
                    title     = product.Title,
                    //usecatoptions = null,
                    userid = product.UserID,
                    weight = Convert.ToInt32(product.Weight),
                    width  = Convert.ToInt32(product.Width),
                });
            }
            return(dbProducts);
        }
Beispiel #15
0
        public DataTable DeserializeDataTable(string name, List <System.Type> colTypes = null)
        {
            var theTable = new DataTable(name);

            /*----------------------------------
             * A first pass to read the header
             * and infer the data types
             * ---------------------------------*/
            var columnNames = new List <string>();
            var columnTypes = new List <Type>();
            int columnCount = 0;
            int counter     = 0;

            using (StringReader reader = new StringReader(_csv)) //Read line by line
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line == "")
                    {
                        continue;
                    }

                    if (counter == 0)
                    {
                        var tokens = line.Split(',');
                        columnCount = tokens.Length - 1;
                        for (int i = 1; i <= columnCount; ++i)
                        {
                            columnNames.Add(tokens[i]);
                        }
                    }
                    else if (colTypes != null && counter == 1)
                    {
                        var tokens = line.Split(',');
                        columnCount = tokens.Length - 1;
                        for (int i = 1; i <= columnCount; ++i)
                        {
                            columnTypes.Add(this.GuessType(tokens[i]));
                        }
                    }
                    else
                    {
                        break;
                    }

                    counter++;
                }
            }

            if (colTypes != null)
            {
                columnTypes = colTypes;
            }
            for (int i = 0; i < columnCount; ++i)
            {
                theTable.Columns.Add(columnNames[i], columnTypes[i]);
            }

            /*----------------------------------
             * A second pass to read the data
             * ---------------------------------*/
            counter = 0;
            using (StringReader reader = new StringReader(_csv))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line == "")
                    {
                        continue;
                    }

                    if (counter == 0)
                    {
                        counter++;
                        continue;
                    }

                    DataRow row = theTable.NewRow();

                    var tokens = line.Split(',');
                    for (int i = 0; i < columnCount; ++i)
                    {
                        if (columnTypes[i] == typeof(DateTime))
                        {
                            row[i] = Convert.ToDateTime(tokens[i + 1]); // +1 because first column is not used.
                        }
                        else if (columnTypes[i] == typeof(double))
                        {
                            row[i] = Convert.ToDouble(tokens[i + 1]);
                        }
                        else if (columnTypes[i] == typeof(int))
                        {
                            row[i] = Convert.ToInt32(tokens[i + 1]);
                        }
                        else
                        {
                            row[i] = tokens[i + 1];
                        }
                    }

                    theTable.Rows.Add(row);
                    counter++;
                }
            }
            return(theTable);
        }
Beispiel #16
0
        private void DataGridViewItemsCellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }

            #region             //Проверка колонки "Выполнено"
            if (e.ColumnIndex == ColumnClosed.Index)
            {
                checkBoxSelectAll.CheckedChanged -= CheckBoxSelectAllCheckedChanged;

                IEnumerable <WorkPackageClosingDataGridViewRow> rows =
                    dataGridViewItems.Rows.OfType <WorkPackageClosingDataGridViewRow>();
                bool checkedValue   = rows.FirstOrDefault(r => (bool)r.Cells[ColumnClosed.Index].Value) != null;
                bool unCheckedValue = rows.FirstOrDefault(r => !(bool)r.Cells[ColumnClosed.Index].Value) != null;
                if (checkedValue && unCheckedValue)
                {
                    checkBoxSelectAll.CheckState = CheckState.Indeterminate;
                }
                else if (checkedValue)
                {
                    checkBoxSelectAll.CheckState = CheckState.Checked;
                }
                else
                {
                    checkBoxSelectAll.CheckState = CheckState.Unchecked;
                }

                checkBoxSelectAll.CheckedChanged += CheckBoxSelectAllCheckedChanged;
            }
            #endregion

            #region             //Проверка колонки "Часы"
            if (e.ColumnIndex == ColumnHours.Index)
            {
                WorkPackageClosingDataGridViewRow row =
                    dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow;
                if (row == null || row.ClosingItem is Component)
                {
                    return;
                }
                DataGridViewCell cell  = dataGridViewItems[e.ColumnIndex, e.RowIndex];
                string           value = cell.Value as string;
                if (value == null)
                {
                    return;
                }
                if (Lifelength.ValidateHours(value))
                {
                    int?totalMinutes = Lifelength.ParseTotalMinutes(value);
                    if (totalMinutes == null)
                    {
                        return;
                    }

                    if (row.MinPerfSource != null &&
                        row.MinPerfSource.TotalMinutes != null &&
                        row.MinPerfSource.TotalMinutes > totalMinutes)
                    {
                        cell.Style.BackColor = Color.Red;
                    }
                    else
                    {
                        cell.Style.BackColor = Color.White;
                    }
                }
                else
                {
                    cell.Style.BackColor = Color.Red;
                }
            }
            #endregion

            #region             //Проверка колонки "Циклы"
            if (e.ColumnIndex == ColumnCycles.Index)
            {
                WorkPackageClosingDataGridViewRow row =
                    dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow;
                if (row == null || row.ClosingItem is Component)
                {
                    return;
                }

                DataGridViewCell cell  = dataGridViewItems[e.ColumnIndex, e.RowIndex];
                string           value = cell.Value as string;
                if (value == null)
                {
                    return;
                }
                if (Lifelength.ValidateCyclesOrDays(value))
                {
                    int?cycles = Lifelength.ParseCyclesOrDays(value);
                    if (cycles == null)
                    {
                        return;
                    }
                    if (row.MinPerfSource != null &&
                        row.MinPerfSource.Cycles != null &&
                        row.MinPerfSource.Cycles > cycles)
                    {
                        cell.Style.BackColor = Color.Red;
                    }
                    else
                    {
                        cell.Style.BackColor = Color.White;
                    }
                }
                else
                {
                    cell.Style.BackColor = Color.Red;
                }
            }
            #endregion

            #region             //Проверка колонки "Дни"
            if (e.ColumnIndex == ColumnDays.Index)
            {
                WorkPackageClosingDataGridViewRow row =
                    dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow;
                if (row == null || row.ClosingItem is Component)
                {
                    return;
                }

                DataGridViewCell cell  = dataGridViewItems[e.ColumnIndex, e.RowIndex];
                string           value = cell.Value as string;
                if (value == null)
                {
                    return;
                }
                if (Lifelength.ValidateCyclesOrDays(value))
                {
                    int?cycles = Lifelength.ParseCyclesOrDays(value);
                    if (cycles == null)
                    {
                        return;
                    }
                    if (row.MinPerfSource != null &&
                        row.MinPerfSource.Days != null &&
                        row.MinPerfSource.Days > cycles)
                    {
                        cell.Style.BackColor = Color.Red;
                    }
                    else
                    {
                        cell.Style.BackColor = Color.White;
                    }
                }
                else
                {
                    cell.Style.BackColor = Color.Red;
                }
            }
            #endregion

            #region             //Проверка колонки "Дата"

            if (e.ColumnIndex == ColumnDate.Index)
            {
                WorkPackageClosingDataGridViewRow row =
                    dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow;
                if (row != null && !(row.ClosingItem is Component))
                {
                    DateTime dateTime = Convert.ToDateTime(row.Cells[ColumnDate.Index].Value);

                    if (row.PrevPerfDate != null && dateTime < row.PrevPerfDate)
                    {
                        row.Cells[ColumnDate.Index].Value = row.PrevPerfDate.Value;
                    }
                    else if (dateTime < new DateTime(1950, 1, 1))
                    {
                        row.Cells[ColumnDate.Index].Value = DateTimeExtend.GetCASMinDateTime();
                    }
                    if (row.NextPerfDate != null && dateTime > row.NextPerfDate)
                    {
                        row.Cells[ColumnDate.Index].Value = row.NextPerfDate.Value;
                    }
                    else if (dateTime > DateTime.Now)
                    {
                        row.Cells[ColumnDate.Index].Value = DateTime.Now;
                    }

                    if (row.ClosingItem.LifeLengthParent is Operator)
                    {
                        row.Cells[ColumnHours.Index].Value  = "n/a";
                        row.Cells[ColumnCycles.Index].Value = "n/a";
                        row.Cells[ColumnDays.Index].Value   = "n/a";
                    }
                    else
                    {
                        Lifelength performanceSource =
                            GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(row.ClosingItem.LifeLengthParent, dateTime);
                        row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null?performanceSource.ToHoursMinutesFormat("") : "n/a";

                        row.Cells[ColumnCycles.Index].Value = performanceSource.Cycles != null?performanceSource.Cycles.ToString() : "n/a";

                        row.Cells[ColumnDays.Index].Value = performanceSource.Days != null?performanceSource.Days.ToString() : "n/a";
                    }
                }
            }
            #endregion
        }
Beispiel #17
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == @"Approve" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    var type     = Convert.ToInt32(hfType.Value);
                    var id       = Convert.ToInt32(hfId.Value);
                    var idNumber = string.Empty;

                    var cApprovalHistory = new CApprovalHistory();
                    var approvalHistory  = cApprovalHistory.Get(type, id, CurrentUserId);
                    approvalHistory.ApprovalDate = DateTime.Now;
                    approvalHistory.ApprovalMemo = tbRemark.Text;
                    // cal
                    int approvalStatus = cApprovalHistory.CheckApprovalStep(type, id);
                    if (approvalStatus == (int)CConstValue.ApprovalStatus.Approved)
                    {
                        approvalStatus = new CGlobal().GetApprovalValue(type);
                    }
                    approvalHistory.ApprovalStep = approvalStatus;
                    // update approvalHistory
                    cApprovalHistory.Update(approvalHistory);

                    //Refund & Commission
                    if (type == (int)CConstValue.Approval.Refund)
                    {
                        var cRefundInfo = new CRefund();
                        var refundInfo  = cRefundInfo.Get(Convert.ToInt32(hfId.Value));

                        refundInfo.ApprovalDate   = approvalHistory.ApprovalDate;
                        refundInfo.ApprovalId     = approvalHistory.ApprovalUser;
                        refundInfo.ApprovalMemo   = approvalHistory.ApprovalMemo;
                        refundInfo.ApprovalStatus = approvalHistory.ApprovalStep;

                        if (cRefundInfo.Update(refundInfo))
                        {
                            //if last approve
                            if (refundInfo.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                var vwRefund      = cRefundInfo.GetVwRefund(refundInfo.RefundId);
                                var refundAmount  = Math.Abs((decimal)vwRefund.RefundAmount);
                                var sumOfMdfAndCp = new CCreditMemo().GetSumOfMdfAndCp(vwRefund.RefundId);

                                var cCreditMemoPayout = new CCreditMemoPayout();
                                var creditMemoPayout  = cCreditMemoPayout.Get(refundInfo.CreditMemoPayoutId);

                                var cCreditMemo = new CCreditMemo();
                                var creditMemo  = cCreditMemo.Get(creditMemoPayout.CreditMemoId);

                                creditMemo.OriginalCreditMemoAmount = refundAmount - sumOfMdfAndCp;
                                creditMemo.CreditMemoStartDate      = DateTime.Now;
                                creditMemo.CreditMemoEndDate        = DateTime.Now.AddYears(1);
                                creditMemo.IsActive    = true;
                                creditMemo.UpdatedId   = CurrentUserId;
                                creditMemo.UpdatedDate = DateTime.Now;

                                // Approved
                                creditMemoPayout.ApprovalStatus = (int)CConstValue.ApprovalStatus.Approved;
                                creditMemoPayout.ApprovalDate   = DateTime.Now;
                                creditMemoPayout.ApprovalId     = CurrentUserId;
                                creditMemoPayout.Amount         = refundAmount;
                                creditMemoPayout.PayoutMethod   = vwRefund.PayoutMethod;
                                creditMemoPayout.IsActive       = true;

                                creditMemoPayout.UpdatedId   = CurrentUserId;
                                creditMemoPayout.UpdatedDate = DateTime.Now;

                                cCreditMemoPayout.Update(creditMemoPayout);

                                if (cCreditMemo.Update(creditMemo))
                                {
                                    var cInvoiceInfo = new CInvoice();
                                    var invoiceInfo  = cInvoiceInfo.Get(refundInfo.InvoiceId);

                                    var cOriginalInvoiceInfo = new CInvoice();
                                    var originalInvoiceInfo  = cOriginalInvoiceInfo.Get(Convert.ToInt32(invoiceInfo.OriginalInvoiceId));

                                    invoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Invoiced; // Invoiced
                                    invoiceInfo.UpdatedId = CurrentUserId;

                                    originalInvoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Cancelled_RF; // Canceled_RF
                                    originalInvoiceInfo.UpdatedId = CurrentUserId;

                                    var startDate = DateTime.Now;
                                    var endDate   = DateTime.Now;

                                    //invoice status update
                                    if (cInvoiceInfo.Update(invoiceInfo) && cOriginalInvoiceInfo.Update(originalInvoiceInfo))
                                    {
                                        // Program
                                        if (invoiceInfo.ProgramRegistrationId != null)
                                        {
                                            var cProgramRegiInfo = new CProgramRegistration();
                                            var programRegiInfo  = cProgramRegiInfo.Get(Convert.ToInt32(invoiceInfo.ProgramRegistrationId));
                                            programRegiInfo.UpdatedId               = CurrentUserId;
                                            programRegiInfo.UpdatedDate             = DateTime.Now;
                                            programRegiInfo.ProgramRegistrationType = 12; // cancel

                                            cProgramRegiInfo.Update(programRegiInfo);

                                            startDate = programRegiInfo.StartDate.Value;
                                            endDate   = programRegiInfo.EndDate.Value;
                                        }
                                        // Homestay
                                        else if (invoiceInfo.HomestayRegistrationId != null)
                                        {
                                            var cHomestayStudentRequest = new CHomestayStudentRequest();
                                            var homestayStudentRequest  = cHomestayStudentRequest.GetHomestayStudentRequest(Convert.ToInt32(invoiceInfo.HomestayRegistrationId));
                                            homestayStudentRequest.UpdateUserId          = CurrentUserId;
                                            homestayStudentRequest.UpdatedDate           = DateTime.Now;
                                            homestayStudentRequest.HomestayStudentStatus = 1; // cancel

                                            cHomestayStudentRequest.Update(homestayStudentRequest);

                                            startDate = homestayStudentRequest.StartDate.Value;
                                            endDate   = homestayStudentRequest.EndDate.Value;
                                        }
                                        // Dormitory
                                        else if (invoiceInfo.DormitoryRegistrationId != null)
                                        {
                                            var cDormitoryStudentRequest = new CDormitoryRegistrations();
                                            var dormitoryStudentRequest  = cDormitoryStudentRequest.GetDormitoryStudentRequest(Convert.ToInt32(invoiceInfo.ProgramRegistrationId));
                                            dormitoryStudentRequest.DormitoryStudentStatus = 1; // cancel
                                            dormitoryStudentRequest.UpdatedId   = CurrentUserId;
                                            dormitoryStudentRequest.UpdatedDate = DateTime.Now;

                                            cDormitoryStudentRequest.Update(dormitoryStudentRequest);

                                            startDate = dormitoryStudentRequest.StartDate.Value;
                                            endDate   = dormitoryStudentRequest.EndDate.Value;
                                        }

                                        // Rev
                                        var cInterimInvoice = new CInvoice();
                                        var interimInvoice  = new Invoice();
                                        CGlobal.Copy(invoiceInfo, interimInvoice);
                                        interimInvoice.OriginalInvoiceId = invoiceInfo.InvoiceId;
                                        interimInvoice.InvoiceType       = (int)CConstValue.InvoiceType.Refund_RV;
                                        interimInvoice.Status            = (int)CConstValue.InvoiceStatus.Invoiced;
                                        interimInvoice.CreatedId         = CurrentUserId;
                                        interimInvoice.CreatedDate       = DateTime.Now;

                                        if (cInterimInvoice.Add(interimInvoice) > 0)
                                        {
                                            var totalDays   = Convert.ToDateTime(endDate) - Convert.ToDateTime(startDate);
                                            var interimDays = Convert.ToDateTime(endDate) - Convert.ToDateTime(refundInfo.RefundDate);
                                            var interimRate = Math.Round((interimDays.TotalDays / totalDays.TotalDays), 2) * 100;

                                            var cInvoiceItem = new CInvoiceItem();
                                            var cOriginalInvoiceItemModels     = cInvoiceItem.GetInvoiceItemModels(invoiceInfo.InvoiceId);
                                            List <InvoiceItem> newInvoiceItems = new List <InvoiceItem>();
                                            foreach (CInvoiceItemModel ori in cOriginalInvoiceItemModels)
                                            {
                                                if (ori.InvoiceCoaItem.RevenueRecognition == 1)
                                                {
                                                    var newInvoiceRevItem = new InvoiceItem();
                                                    CGlobal.Copy(ori.InvoiceItem, newInvoiceRevItem);
                                                    newInvoiceRevItem.InvoiceId = interimInvoice.InvoiceId;

                                                    newInvoiceRevItem.StandardPrice *= (decimal)interimRate;
                                                    newInvoiceRevItem.StudentPrice  *= (decimal)interimRate;
                                                    newInvoiceRevItem.AgencyPrice   *= (decimal)interimRate;

                                                    newInvoiceRevItem.CreatedId   = CurrentUserId;
                                                    newInvoiceRevItem.CreatedDate = DateTime.Now;
                                                    newInvoiceRevItem.Remark      = "Refund Rev";
                                                    newInvoiceItems.Add(newInvoiceRevItem);
                                                }
                                            }

                                            if (newInvoiceItems.Count > 0)
                                            {
                                                // copy invoiceItems
                                                if (cInvoiceItem.Add(newInvoiceItems))
                                                {
                                                    RunClientScript("Close();");
                                                }
                                                else
                                                {
                                                    ShowMessage("failed to update inqury (Refund Ref Invoice Item)");
                                                }
                                            }
                                            else
                                            {
                                                RunClientScript("Close();");
                                            }
                                        }
                                        else
                                        {
                                            ShowMessage("failed to update inqury (Refund Ref Invoice)");
                                        }
                                    }
                                    else
                                    {
                                        ShowMessage("failed to update inqury (Original Invoice and Refund Invoice)");
                                    }
                                }
                                else
                                {
                                    ShowMessage("failed to update inqury (CreditMemo Info)");
                                }
                            }
                            else
                            {
                                RunClientScript("Close();");
                            }
                        }
                        else
                        {
                            ShowMessage("failed to update inqury (Refund Info)");
                        }
                    }
                    // Agency
                    else if (type == (int)CConstValue.Approval.Agency)
                    {
                        try
                        {
                            var cAgency = new CAgency();
                            var agency  = cAgency.Get(id);

                            idNumber              = agency.AgencyNumber;
                            agency.ApprovalDate   = approvalHistory.ApprovalDate;
                            agency.ApprovalId     = approvalHistory.ApprovalUser;
                            agency.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            agency.ApprovalStatus = approvalHistory.ApprovalStep;

                            cAgency.Update(agency);

                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // BusinessTrip
                    else if (type == (int)CConstValue.Approval.BusinessTrip)
                    {
                        try
                        {
                            var cBusinessTrip = new CBusinessTrip();
                            var businessTrip  = cBusinessTrip.Get(id);

                            businessTrip.ApprovalDate   = approvalHistory.ApprovalDate;
                            businessTrip.ApprovalId     = approvalHistory.ApprovalUser;
                            businessTrip.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            businessTrip.ApprovalStatus = approvalHistory.ApprovalStep;

                            cBusinessTrip.Update(businessTrip);

                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Purchase Order
                    else if (type == (int)CConstValue.Approval.PurchaseOrder)
                    {
                        try
                        {
                            var cPurchaseOrder = new CPurchaseOrder();
                            var purchaseOrder  = cPurchaseOrder.Get(id);

                            purchaseOrder.ApprovalDate   = approvalHistory.ApprovalDate;
                            purchaseOrder.ApprovalId     = approvalHistory.ApprovalUser;
                            purchaseOrder.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            purchaseOrder.ApprovalStatus = approvalHistory.ApprovalStep;

                            cPurchaseOrder.Update(purchaseOrder);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Package Program
                    else if (type == (int)CConstValue.Approval.Package)
                    {
                        try
                        {
                            var cP             = new CPackageProgram();
                            var packageProgram = cP.GetPackageProgram(id);

                            packageProgram.ApprovalDate   = approvalHistory.ApprovalDate;
                            packageProgram.ApprovalId     = approvalHistory.ApprovalUser;
                            packageProgram.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            packageProgram.ApprovalStatus = approvalHistory.ApprovalStep;
                            if (packageProgram.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                packageProgram.IsActive = true;
                            }

                            cP.Update(packageProgram);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    //Scholarship//
                    else if (type == (int)CConstValue.Approval.Scholarship)
                    {
                        try
                        {
                            var cScholar = new CScholarship();
                            var scholar  = cScholar.Get(Convert.ToInt32(id));

                            idNumber               = scholar.ScholarshipMasterNo;
                            scholar.ApprovalDate   = approvalHistory.ApprovalDate;
                            scholar.ApprovalId     = approvalHistory.ApprovalUser;
                            scholar.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            scholar.ApprovalStatus = approvalHistory.ApprovalStep;
                            if (scholar.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                scholar.IsActive = true;
                            }

                            cScholar.Update(scholar);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    //Promotion//
                    else if (type == (int)CConstValue.Approval.Promotion)
                    {
                        try
                        {
                            var cPromo = new CPromotion();
                            var promo  = cPromo.Get(Convert.ToInt32(id));

                            idNumber             = promo.PromotionMasterNo;
                            promo.ApprovalDate   = approvalHistory.ApprovalDate;
                            promo.ApprovalId     = approvalHistory.ApprovalUser;
                            promo.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            promo.ApprovalStatus = approvalHistory.ApprovalStep;
                            if (promo.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                promo.IsActive = true;
                            }

                            cPromo.Update(promo);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Expense Program
                    else if (type == (int)CConstValue.Approval.Expense)
                    {
                        try
                        {
                            var cExpense = new CExpense();
                            var expense  = cExpense.Get(id);

                            expense.ApprovalDate   = approvalHistory.ApprovalDate;
                            expense.ApprovalId     = approvalHistory.ApprovalUser;
                            expense.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            expense.ApprovalStatus = approvalHistory.ApprovalStep;

                            cExpense.Update(expense);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Hire
                    else if (type == (int)CConstValue.Approval.Hire)
                    {
                        try
                        {
                            var cHire = new CHire();
                            var hire  = cHire.Get(id);

                            hire.ApprovalDate   = approvalHistory.ApprovalDate;
                            hire.ApprovalId     = approvalHistory.ApprovalUser;
                            hire.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            hire.ApprovalStatus = approvalHistory.ApprovalStep;

                            cHire.Update(hire);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Vacation
                    else if (type == (int)CConstValue.Approval.Vacation)
                    {
                        try
                        {
                            var cVacationDetail = new CVacation();
                            var vacation        = cVacationDetail.Get(id);

                            vacation.ApprovalDate   = approvalHistory.ApprovalDate;
                            vacation.ApprovalId     = approvalHistory.ApprovalUser;
                            vacation.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            vacation.ApprovalStatus = approvalHistory.ApprovalStep;

                            cVacationDetail.Update(vacation);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // CreditMemoPayout
                    else if (type == (int)CConstValue.Approval.CreditMemoPayout)
                    {
                        try
                        {
                            var cCreditMemo = new CCreditMemoPayout();
                            var creditMemo  = cCreditMemo.Get(id);

                            creditMemo.ApprovalDate   = approvalHistory.ApprovalDate;
                            creditMemo.ApprovalId     = approvalHistory.ApprovalUser;
                            creditMemo.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            creditMemo.ApprovalStatus = approvalHistory.ApprovalStep;

                            cCreditMemo.Update(creditMemo);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }


                    if (approvalHistory.ApprovalStep != (int)CConstValue.ApprovalStatus.Approved) //if has a next approver, request approve
                    {
                        var approvalInfo = new CApproval();
                        var supervisor   = approvalInfo.GetSupuervisor(type, CurrentUserId);

                        if (supervisor > 0)
                        {
                            var cNextApprove = new CApprovalHistory();
                            var nextApprove  = cNextApprove.Get(type, id, supervisor);

                            nextApprove.IsApprovalRequest = true;
                            cNextApprove.Update(nextApprove);
                        }

                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToApproveUserAndRequestUser, id, idNumber, CurrentUserId);
                    }
                    // approved
                    else
                    {
                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToRequestUser, id, idNumber, CurrentUserId);
                    }
                }
            }
        }