示例#1
0
        /// <summary>
        /// Add new object and return id
        /// 12/Oct/2005 Thachnn: fix bug injection
        /// </summary>
        /// <param name="pobjFieldGroup">Object to add</param>
        /// <returns>New ID</returns>
        public int AddAndReturnID(object pobjFieldGroup)
        {
            const string METHOD_NAME = THIS + ".AddAndReturnID()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                Sys_FieldGroupVO objObject = (Sys_FieldGroupVO)pobjFieldGroup;
                string           strSql    = String.Empty;
                Utils            utils     = new Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand("", oconPCS);

                strSql = "INSERT INTO Sys_FieldGroup("
                         + Sys_FieldGroupTable.GROUPCODE_FLD + ","
                         + Sys_FieldGroupTable.GROUPORDER_FLD + ","
                         + Sys_FieldGroupTable.GROUPLEVEL_FLD + ","
                         + Sys_FieldGroupTable.GROUPNAMEVN_FLD + ","
                         + Sys_FieldGroupTable.GROUPNAMEEN_FLD + ","
                         + Sys_FieldGroupTable.GROUPNAMEJP_FLD + ","
                         + Sys_FieldGroupTable.REPORTID_FLD + ","
                         + Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD + ")"
                         + "VALUES(?,?,?,?,?,?,?,?)";
                strSql += " ; SELECT @@IDENTITY AS NEWID";

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPCODE_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPCODE_FLD].Value = objObject.GroupCode;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPORDER_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPORDER_FLD].Value = objObject.GroupOrder;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPLEVEL_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPLEVEL_FLD].Value = objObject.GroupLevel;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPNAMEVN_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPNAMEVN_FLD].Value = objObject.GroupNameVN;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPNAMEEN_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPNAMEEN_FLD].Value = objObject.GroupNameEN;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPNAMEJP_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPNAMEJP_FLD].Value = objObject.GroupNameJP;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.REPORTID_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.REPORTID_FLD].Value = objObject.ReportID;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD, OleDbType.Integer));
                if (objObject.ParentFieldGroupID > 0)
                {
                    ocmdPCS.Parameters[Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD].Value = objObject.ParentFieldGroupID;
                }
                else
                {
                    ocmdPCS.Parameters[Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD].Value = DBNull.Value;
                }

                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                object objResult = ocmdPCS.ExecuteScalar();
                if (objResult != null && objResult != DBNull.Value)
                {
                    return(int.Parse(objResult.ToString()));
                }
                else
                {
                    return(0);
                }
            }
            catch (OleDbException ex)
            {
                if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
                {
                    throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);
                }
                else
                {
                    throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
                }
            }
            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }
            catch (Exception ex)
            {
                throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
            }
            finally
            {
                if (oconPCS != null)
                {
                    if (oconPCS.State != ConnectionState.Closed)
                    {
                        oconPCS.Close();
                    }
                }
            }
        }
示例#2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from Sys_FieldGroup
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       Sys_FieldGroupVO
        ///    </Outputs>
        ///    <Returns>
        ///       Sys_FieldGroupVO
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Saturday, September 17, 2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************

        public object GetObjectVO(int pintID)
        {
            const string METHOD_NAME = THIS + ".GetObjectVO()";

            OleDbDataReader odrPCS  = null;
            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                string strSql = String.Empty;
                strSql = "SELECT "
                         + Sys_FieldGroupTable.FIELDGROUPID_FLD + ","
                         + Sys_FieldGroupTable.GROUPCODE_FLD + ","
                         + Sys_FieldGroupTable.GROUPORDER_FLD + ","
                         + Sys_FieldGroupTable.GROUPLEVEL_FLD + ","
                         + Sys_FieldGroupTable.GROUPNAMEVN_FLD + ","
                         + Sys_FieldGroupTable.GROUPNAMEEN_FLD + ","
                         + Sys_FieldGroupTable.GROUPNAMEJP_FLD + ","
                         + Sys_FieldGroupTable.REPORTID_FLD + ","
                         + Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD
                         + " FROM " + Sys_FieldGroupTable.TABLE_NAME
                         + " WHERE " + Sys_FieldGroupTable.FIELDGROUPID_FLD + "=" + pintID;

                Utils utils = new Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSql, oconPCS);

                ocmdPCS.Connection.Open();
                odrPCS = ocmdPCS.ExecuteReader();

                Sys_FieldGroupVO objObject = new Sys_FieldGroupVO();

                while (odrPCS.Read())
                {
                    objObject.FieldGroupID       = int.Parse(odrPCS[Sys_FieldGroupTable.FIELDGROUPID_FLD].ToString().Trim());
                    objObject.GroupCode          = odrPCS[Sys_FieldGroupTable.GROUPCODE_FLD].ToString().Trim();
                    objObject.GroupOrder         = int.Parse(odrPCS[Sys_FieldGroupTable.GROUPORDER_FLD].ToString().Trim());
                    objObject.GroupLevel         = int.Parse(odrPCS[Sys_FieldGroupTable.GROUPLEVEL_FLD].ToString().Trim());
                    objObject.GroupNameVN        = odrPCS[Sys_FieldGroupTable.GROUPNAMEVN_FLD].ToString().Trim();
                    objObject.GroupNameEN        = odrPCS[Sys_FieldGroupTable.GROUPNAMEEN_FLD].ToString().Trim();
                    objObject.GroupNameJP        = odrPCS[Sys_FieldGroupTable.GROUPNAMEJP_FLD].ToString().Trim();
                    objObject.ReportID           = odrPCS[Sys_FieldGroupTable.REPORTID_FLD].ToString().Trim();
                    objObject.ParentFieldGroupID = int.Parse(odrPCS[Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD].ToString().Trim());
                }
                return(objObject);
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (Exception ex)
            {
                throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
            }

            finally
            {
                if (oconPCS != null)
                {
                    if (oconPCS.State != ConnectionState.Closed)
                    {
                        oconPCS.Close();
                    }
                }
            }
        }
示例#3
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to update data to Sys_FieldGroup
        ///    </Description>
        ///    <Inputs>
        ///       Sys_FieldGroupVO
        ///    </Inputs>
        ///    <Outputs>
        ///
        ///    </Outputs>
        ///    <Returns>
        ///
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       09-Dec-2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public void Update(object pobjObjecVO)
        {
            const string METHOD_NAME = THIS + ".Update()";

            Sys_FieldGroupVO objObject = (Sys_FieldGroupVO)pobjObjecVO;


            //prepare value for parameters
            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                string strSql = String.Empty;
                Utils  utils  = new Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSql, oconPCS);
                strSql  = "UPDATE Sys_FieldGroup SET "
                          + Sys_FieldGroupTable.GROUPCODE_FLD + "=   ?" + ","
                          + Sys_FieldGroupTable.GROUPORDER_FLD + "=   ?" + ","
                          + Sys_FieldGroupTable.GROUPLEVEL_FLD + "=   ?" + ","
                          + Sys_FieldGroupTable.GROUPNAMEVN_FLD + "=   ?" + ","
                          + Sys_FieldGroupTable.GROUPNAMEEN_FLD + "=   ?" + ","
                          + Sys_FieldGroupTable.GROUPNAMEJP_FLD + "=   ?" + ","
                          + Sys_FieldGroupTable.REPORTID_FLD + "=   ?" + ","
                          + Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD + "=  ?"
                          + " WHERE " + Sys_FieldGroupTable.FIELDGROUPID_FLD + "= ?";

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPCODE_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPCODE_FLD].Value = objObject.GroupCode;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPORDER_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPORDER_FLD].Value = objObject.GroupOrder;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPLEVEL_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPLEVEL_FLD].Value = objObject.GroupLevel;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPNAMEVN_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPNAMEVN_FLD].Value = objObject.GroupNameVN;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPNAMEEN_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPNAMEEN_FLD].Value = objObject.GroupNameEN;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.GROUPNAMEJP_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.GROUPNAMEJP_FLD].Value = objObject.GroupNameJP;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.REPORTID_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.REPORTID_FLD].Value = objObject.ReportID;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD].Value = objObject.ParentFieldGroupID;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.FIELDGROUPID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_FieldGroupTable.FIELDGROUPID_FLD].Value = objObject.FieldGroupID;


                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
                {
                    throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);
                }
                else
                {
                    throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
                }
            }

            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }
            catch (Exception ex)
            {
                throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
            }

            finally
            {
                if (oconPCS != null)
                {
                    if (oconPCS.State != ConnectionState.Closed)
                    {
                        oconPCS.Close();
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Get all field group of a report
        /// </summary>
        /// <param name="pstrReportID">Report ID</param>
        /// <returns>List of field group</returns>
        public ArrayList GetAllGroups(string pstrReportID)
        {
            const string METHOD_NAME = THIS + ".GetAllGroups()";

            OleDbDataReader odrPCS  = null;
            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                string strSql = String.Empty;
                strSql = "SELECT "
                         + Sys_FieldGroupTable.FIELDGROUPID_FLD + ","
                         + Sys_FieldGroupTable.GROUPCODE_FLD + ","
                         + Sys_FieldGroupTable.GROUPORDER_FLD + ","
                         + Sys_FieldGroupTable.GROUPLEVEL_FLD + ","
                         + Sys_FieldGroupTable.GROUPNAMEVN_FLD + ","
                         + Sys_FieldGroupTable.GROUPNAMEEN_FLD + ","
                         + Sys_FieldGroupTable.GROUPNAMEJP_FLD + ","
                         + Sys_FieldGroupTable.REPORTID_FLD + ","
                         + Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD
                         + " FROM " + Sys_FieldGroupTable.TABLE_NAME
                         + " WHERE " + Sys_FieldGroupTable.REPORTID_FLD + "=?"
                         + " ORDER BY " + Sys_FieldGroupTable.GROUPORDER_FLD + "=?";

                Utils utils = new Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSql, oconPCS);

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_FieldGroupTable.REPORTID_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_FieldGroupTable.REPORTID_FLD].Value = pstrReportID;

                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                odrPCS = ocmdPCS.ExecuteReader();

                ArrayList arrResult = new ArrayList();
                while (odrPCS.Read())
                {
                    Sys_FieldGroupVO objObject = new Sys_FieldGroupVO();
                    objObject.FieldGroupID = int.Parse(odrPCS[Sys_FieldGroupTable.FIELDGROUPID_FLD].ToString().Trim());
                    objObject.GroupCode    = odrPCS[Sys_FieldGroupTable.GROUPCODE_FLD].ToString().Trim();
                    objObject.GroupOrder   = int.Parse(odrPCS[Sys_FieldGroupTable.GROUPORDER_FLD].ToString().Trim());
                    objObject.GroupLevel   = int.Parse(odrPCS[Sys_FieldGroupTable.GROUPLEVEL_FLD].ToString().Trim());
                    objObject.GroupNameVN  = odrPCS[Sys_FieldGroupTable.GROUPNAMEVN_FLD].ToString().Trim();
                    objObject.GroupNameEN  = odrPCS[Sys_FieldGroupTable.GROUPNAMEEN_FLD].ToString().Trim();
                    objObject.GroupNameJP  = odrPCS[Sys_FieldGroupTable.GROUPNAMEJP_FLD].ToString().Trim();
                    objObject.ReportID     = odrPCS[Sys_FieldGroupTable.REPORTID_FLD].ToString().Trim();
                    if (odrPCS[Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD] != DBNull.Value)
                    {
                        objObject.ParentFieldGroupID = int.Parse(odrPCS[Sys_FieldGroupTable.PARENTFIELDGROUPID_FLD].ToString().Trim());
                    }

                    arrResult.Add(objObject);
                }
                arrResult.TrimToSize();
                return(arrResult);
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (Exception ex)
            {
                throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
            }

            finally
            {
                if (oconPCS != null)
                {
                    if (oconPCS.State != ConnectionState.Closed)
                    {
                        oconPCS.Close();
                    }
                }
            }
        }