Пример #1
0
        public JsonResult InsertCalenderDetail(Calendar _param)
        {
            int result = 0;

            try
            {
                DaoFactory.BeginTransaction();

                Calendar calendar = DaoFactory.GetData <Calendar>("Manage.SelCalendar", new Calendar {
                    Type = CommonConstant.TYPE_CALENDAR, OID = _param.OID
                });
                List <CalendarDetail> lCalendarDetails = DaoFactory.GetList <CalendarDetail>("Manage.SelCalenderDetail", new CalendarDetail {
                    CalendarOID = calendar.OID
                });
                if (lCalendarDetails != null && lCalendarDetails.Count > 0)
                {
                    DObjectRepository.UdtLatestDObject(new DObject {
                        OID = calendar.OID
                    });
                    DObject dObj = new DObject();
                    dObj.Name    = calendar.Name;
                    dObj.Type    = CommonConstant.TYPE_CALENDAR;
                    dObj.TableNm = CommonConstant.TABLE_CALENDAR;
                    dObj.TdmxOID = calendar.TdmxOID;
                    result       = DObjectRepository.InsDObject(dObj);

                    Calendar tmpCalendar = new Calendar();
                    tmpCalendar.OID        = result;
                    tmpCalendar.WorkingDay = calendar.WorkingDay;
                    DaoFactory.SetInsert("Manage.InsCalendar", tmpCalendar);
                }
                else
                {
                    result = Convert.ToInt32(calendar.OID);
                }

                if (_param.CalendarDetails != null && _param.CalendarDetails.Count > 0)
                {
                    _param.CalendarDetails.ForEach(item =>
                    {
                        item.CalendarOID = result;
                        DaoFactory.SetInsert("Manage.InsCalendarDetail", item);
                    });
                }
                DaoFactory.Commit();
            }
            catch (Exception ex)
            {
                DaoFactory.Rollback();
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
            return(Json(result));
        }