Beispiel #1
0
        /// <summary>
        /// Switch two field order
        /// </summary>
        /// <param name="pobjSourceField">Source Field</param>
        /// <param name="pobjDestField">Destination Field</param>

        public void SwitchFields(object pobjSourceField, object pobjDestField)
        {
            sys_ReportFieldsDS dsReportField = new sys_ReportFieldsDS();

            dsReportField.UpdateByName(pobjSourceField);
            dsReportField.UpdateByName(pobjDestField);
        }
Beispiel #2
0
        /// <summary>
        /// Insert a new record into database
        /// </summary>

        public int AddAndReturnID(object pobjFieldGroup, ArrayList parrSelectedItem)
        {
            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();
                // get current field group order
                voFieldGroup.GroupOrder = dsFieldGroup.GetFieldGroupOrder(voFieldGroup.ReportID, voFieldGroup.ParentFieldGroupID) + 1;
                // save new field group to database
                int intNewID = dsFieldGroup.AddAndReturnID(voFieldGroup);
                // save all selected sub group/field to database if any
                for (int i = 0; i < parrSelectedItem.Count; i++)
                {
                    switch (voFieldGroup.GroupLevel)
                    {
                    case (int)GroupFieldLevel.One:
                        // update sub group
                        Sys_FieldGroupVO voSubGroup = (Sys_FieldGroupVO)parrSelectedItem[i];
                        // parent field group id
                        voSubGroup.ParentFieldGroupID = intNewID;
                        // new order in group
                        voSubGroup.GroupOrder = i + 1;
                        // save to database
                        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 = intNewID;
                        voFieldGroupDetail.ReportID     = voFieldGroup.ReportID;
                        voFieldGroupDetail.FieldName    = voReportField.FieldName;
                        // save to database
                        dsFieldGroupDetail.Add(voFieldGroupDetail);
                        break;
                    }
                }
                return(intNewID);
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public bool MoveDownField(string pstrReportID, string pstrFieldName)
        {
            const string       METHOD_NAME     = THIS + ".MoveDownField()";
            bool               blnResult       = true;
            sys_ReportFieldsDS dsReportField   = new sys_ReportFieldsDS();
            sys_ReportFieldsVO voPreviousField = new sys_ReportFieldsVO();
            sys_ReportFieldsVO voCurrentField  = new sys_ReportFieldsVO();
            ArrayList          arrFields       = new ArrayList();

            arrFields = dsReportField.GetObjectVOs(pstrReportID);
            for (int i = 0; i < arrFields.Count; i++)
            {
                sys_ReportFieldsVO voReportField = (sys_ReportFieldsVO)arrFields[i];
                string             strFieldName  = voReportField.FieldName;
                if (strFieldName.Equals(pstrFieldName))
                {
                    int intCurrentOrder = voReportField.FieldOrder;
                    // if current order reached the bottom of layout then return false
                    if (intCurrentOrder >= arrFields.Count)
                    {
                        blnResult = false;
                    }
                    else
                    {
                        // get the previous group
                        voPreviousField = (sys_ReportFieldsVO)arrFields[i + 1];
                        // get the current group
                        voCurrentField = (sys_ReportFieldsVO)arrFields[i];
                        // switch order
                        voCurrentField.FieldOrder  = voPreviousField.FieldOrder;
                        voPreviousField.FieldOrder = intCurrentOrder;

                        //update two rows into database
                        dsReportField.UpdateByName(voPreviousField);
                        dsReportField.UpdateByName(voCurrentField);
                        blnResult = true;
                    }
                }
            }
            return(blnResult);
        }
Beispiel #4
0
        public bool MoveUpField(string pstrReportID, string pstrFieldName)
        {
            bool blnResult = true;
            sys_ReportFieldsDS dsReportField   = new sys_ReportFieldsDS();
            sys_ReportFieldsVO voPreviousField = new sys_ReportFieldsVO();
            sys_ReportFieldsVO voCurrentField  = new sys_ReportFieldsVO();
            ArrayList          arrFields       = new ArrayList();

            arrFields = dsReportField.GetObjectVOs(pstrReportID);
            for (int i = 0; i < arrFields.Count; i++)
            {
                sys_ReportFieldsVO voReportField = (sys_ReportFieldsVO)arrFields[i];
                string             strFieldName  = voReportField.FieldName;
                if (strFieldName.Equals(pstrFieldName))
                {
                    int intCurrentOrder = voReportField.FieldOrder;
                    // if current order reached the top of layout then return false
                    if (intCurrentOrder <= 1)
                    {
                        blnResult = false;
                    }
                    else
                    {
                        // get previous group
                        voPreviousField = (sys_ReportFieldsVO)arrFields[i - 1];
                        // get current group
                        voCurrentField = (sys_ReportFieldsVO)arrFields[i];
                        // switch order between two groups
                        voCurrentField.FieldOrder  = voPreviousField.FieldOrder;
                        voPreviousField.FieldOrder = intCurrentOrder;

                        //update two rows into database
                        dsReportField.UpdateByName(voPreviousField);
                        dsReportField.UpdateByName(voCurrentField);
                        blnResult = true;
                    }
                }
            }
            return(blnResult);
        }
Beispiel #5
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 #6
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 #7
0
        public void Update(object pobjObjecVO)
        {
            sys_ReportFieldsDS templateDS = new sys_ReportFieldsDS();

            templateDS.UpdateByName(pobjObjecVO);
        }
Beispiel #8
0
        /// <summary>
        /// Update Report field by name
        /// </summary>
        /// <param name="pobjObjectVO">sys_ReportFieldsVO</param>

        public void UpdateByName(object pobjObjectVO)
        {
            sys_ReportFieldsDS dsReportField = new sys_ReportFieldsDS();

            dsReportField.UpdateByName(pobjObjectVO);
        }