Beispiel #1
0
        /// <summary>
        /// Delete record by condition
        /// </summary>

        public void Delete(object pObjectVO, ArrayList parrSelected)
        {
            try
            {
                Sys_FieldGroupVO       voFieldGroup       = (Sys_FieldGroupVO)pObjectVO;
                Sys_FieldGroupDS       dsFieldGroup       = new Sys_FieldGroupDS();
                sys_ReportFieldsDS     dsReportField      = new sys_ReportFieldsDS();
                Sys_FieldGroupDetailDS dsFieldGroupDetail = new Sys_FieldGroupDetailDS();
                int intCurrentGroupOrder = dsFieldGroup.GetFieldGroupOrder(voFieldGroup.ReportID, 0);
                int intCurrentFieldOrder = dsReportField.GetMaxFieldOrder(voFieldGroup.ReportID);
                for (int i = 0; i < parrSelected.Count; i++)
                {
                    switch (voFieldGroup.GroupLevel)
                    {
                    case (int)GroupFieldLevel.One:
                        // update sub group (order and parent id)
                        Sys_FieldGroupVO voSubGroup = (Sys_FieldGroupVO)parrSelected[i];
                        voSubGroup.ParentFieldGroupID = 0;
                        voSubGroup.GroupOrder         = intCurrentGroupOrder + i + 1;
                        dsFieldGroup.Update(voSubGroup);
                        break;

                    case (int)GroupFieldLevel.Two:
                        // update report field
                        sys_ReportFieldsVO voReportField = (sys_ReportFieldsVO)parrSelected[i];
                        // new field order in group
                        voReportField.FieldOrder = intCurrentFieldOrder + i + 1;
                        dsReportField.UpdateByName(voReportField);
                        // delete field group detail records first
                        dsFieldGroupDetail.Delete(voFieldGroup.FieldGroupID, voFieldGroup.ReportID);
                        break;
                    }
                }
                // delete field group
                dsFieldGroup.Delete(voFieldGroup.FieldGroupID);
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Update into Database
        /// </summary>

        public void Update(object pobjFieldGroup, ArrayList parrSelectedItem, ArrayList parrAvailableItem)
        {
            try
            {
                Sys_FieldGroupVO       voFieldGroup       = (Sys_FieldGroupVO)pobjFieldGroup;
                Sys_FieldGroupDS       dsFieldGroup       = new Sys_FieldGroupDS();
                sys_ReportFieldsDS     dsReportField      = new sys_ReportFieldsDS();
                Sys_FieldGroupDetailDS dsFieldGroupDetail = new Sys_FieldGroupDetailDS();
                // update Field Group
                dsFieldGroup.Update(voFieldGroup);
                int intCurrentGroupOrder = dsFieldGroup.GetFieldGroupOrder(voFieldGroup.ReportID, 0);
                int intCurrentFieldOrder = dsReportField.GetMaxFieldOrder(voFieldGroup.ReportID);
                for (int i = 0; i < parrAvailableItem.Count; i++)
                {
                    switch (voFieldGroup.GroupLevel)
                    {
                    case (int)GroupFieldLevel.One:
                        Sys_FieldGroupVO voSubGroup = (Sys_FieldGroupVO)parrAvailableItem[i];
                        // remove parent field group
                        voSubGroup.ParentFieldGroupID = 0;
                        voSubGroup.GroupOrder         = intCurrentGroupOrder + 1 + i;
                        dsFieldGroup.Update(voSubGroup);
                        break;

                    case (int)GroupFieldLevel.Two:
                        // update report field
                        sys_ReportFieldsVO voReportField = (sys_ReportFieldsVO)parrSelectedItem[i];
                        // new field order in group
                        voReportField.FieldOrder = intCurrentFieldOrder + i + 1;
                        dsReportField.UpdateByName(voReportField);
                        // create new Field Group Detail
                        Sys_FieldGroupDetailVO voFieldGroupDetail = new Sys_FieldGroupDetailVO();
                        voFieldGroupDetail.FieldGroupID = voFieldGroup.FieldGroupID;
                        voFieldGroupDetail.ReportID     = voFieldGroup.ReportID;
                        voFieldGroupDetail.FieldName    = voReportField.FieldName;
                        // save to database
                        dsFieldGroupDetail.Add(voFieldGroupDetail);
                        break;
                    }
                }
                // delete old field group detail
                dsFieldGroupDetail.Delete(voFieldGroup.FieldGroupID, voFieldGroup.ReportID);
                // update selected group/field
                for (int i = 0; i < parrSelectedItem.Count; i++)
                {
                    switch (voFieldGroup.GroupLevel)
                    {
                    case (int)GroupFieldLevel.One:
                        Sys_FieldGroupVO voSubGroup = (Sys_FieldGroupVO)parrSelectedItem[i];
                        voSubGroup.ParentFieldGroupID = voFieldGroup.FieldGroupID;
                        voSubGroup.GroupOrder         = i + 1;
                        dsFieldGroup.Update(voSubGroup);
                        break;

                    case (int)GroupFieldLevel.Two:
                        // update report field
                        sys_ReportFieldsVO voReportField = (sys_ReportFieldsVO)parrSelectedItem[i];
                        // new field order in group
                        voReportField.FieldOrder = i + 1;
                        dsReportField.UpdateByName(voReportField);
                        // create new Field Group Detail
                        Sys_FieldGroupDetailVO voFieldGroupDetail = new Sys_FieldGroupDetailVO();
                        voFieldGroupDetail.FieldGroupID = voFieldGroup.FieldGroupID;
                        voFieldGroupDetail.ReportID     = voFieldGroup.ReportID;
                        voFieldGroupDetail.FieldName    = voReportField.FieldName;
                        // save to database
                        dsFieldGroupDetail.Add(voFieldGroupDetail);
                        break;
                    }
                }
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public int GetMaxFieldOrder(string pstrReportID)
        {
            sys_ReportFieldsDS dsField = new sys_ReportFieldsDS();

            return(dsField.GetMaxFieldOrder(pstrReportID));
        }