Exemple #1
0
        public void Add(object pobjObjectVO)
        {
            const string METHOD_NAME = THIS + ".Add()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO Sys_Right("
                         + Sys_RightTable.PERMISSION_FLD + ","
                         + Sys_RightTable.ROLEID_FLD + ","
                         + Sys_RightTable.MENU_ENTRYID_FLD + ")"
                         + "VALUES(?,?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_RightTable.PERMISSION_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_RightTable.PERMISSION_FLD].Value = objObject.Permission;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_RightTable.ROLEID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_RightTable.ROLEID_FLD].Value = objObject.RoleID;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_RightTable.MENU_ENTRYID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_RightTable.MENU_ENTRYID_FLD].Value = objObject.Menu_EntryID;

                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.DUPLICATE_KEY, 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();
                    }
                }
            }
        }
Exemple #2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from Sys_Right
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       Sys_RightVO
        ///    </Outputs>
        ///    <Returns>
        ///       Sys_RightVO
        ///    </Returns>
        ///    <Authors>
        ///       Code Generate
        ///    </Authors>
        ///    <History>
        ///       Monday, January 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_RightTable.RIGHTID_FLD + ","
                         + Sys_RightTable.PERMISSION_FLD + ","
                         + Sys_RightTable.ROLEID_FLD + ","
                         + Sys_RightTable.MENU_ENTRYID_FLD
                         + " FROM " + Sys_RightTable.TABLE_NAME
                         + " WHERE " + Sys_RightTable.RIGHTID_FLD + "=" + pintID;

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

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

                Sys_RightVO objObject = new Sys_RightVO();

                while (odrPCS.Read())
                {
                    objObject.RightID      = int.Parse(odrPCS[Sys_RightTable.RIGHTID_FLD].ToString());
                    objObject.Permission   = int.Parse(odrPCS[Sys_RightTable.PERMISSION_FLD].ToString());
                    objObject.RoleID       = int.Parse(odrPCS[Sys_RightTable.ROLEID_FLD].ToString());
                    objObject.Menu_EntryID = int.Parse(odrPCS[Sys_RightTable.MENU_ENTRYID_FLD].ToString());
                }
                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();
                    }
                }
            }
        }
Exemple #3
0
        public DataTable SearchValueForButtonColumn(string[] pstrColumnInfor, string pstrValue)
        {
            //strArrayValue[0] - From TableName
            //strArrayValue[1] - Value Field
            //strArrayValue[2] - Display Field 1
            //strArrayValue[3] - Display Field 2
            //strArrayValue[4] - Ogininal Column Name
            //strArrayValue[5] - Original filter column

            const string METHOD_NAME = THIS + ".SearchValueForButtonColumn()";
            DataSet      dstPCS      = new DataSet();

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                string strSqlStatement = String.Empty;
                string strTableName    = pstrColumnInfor[0];

                //build the SELECT Statement
                strSqlStatement = "SELECT " + pstrColumnInfor[1] + "," + pstrColumnInfor[2];
                if (pstrColumnInfor[3] != String.Empty)
                {
                    strSqlStatement += "," + pstrColumnInfor[3];
                }
                strSqlStatement += " FROM " + pstrColumnInfor[0];
                strSqlStatement += " WHERE " + pstrColumnInfor[5] + "='" + pstrValue.Replace("'", "''") + "'";

                DataAccess.Utils utils = new DataAccess.Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSqlStatement, oconPCS);
                ocmdPCS.Connection.Open();

                OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
                odadPCS.Fill(dstPCS, strTableName);
                return(dstPCS.Tables[0]);
            }
            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();
                    }
                }
            }
        }
Exemple #4
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get the max value of last row in sys_table
        ///    </Description>
        ///    <Inputs>
        ///        GroupID
        ///    </Inputs>
        ///    <Outputs>
        ///      Max Table Order
        ///    </Outputs>
        ///    <Returns>
        ///       int
        ///    </Returns>
        ///    <Authors>
        ///       NgocHT
        ///       12/Oct/2005 Thachnn: fix bug injection
        ///    </Authors>
        ///    <History>
        ///       28-Dec-2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public int GetMaxReportOrder(string pstrGroupID)
        {
            const string    METHOD_NAME = THIS + ".GetMaxReportOrder()";
            OleDbConnection oconPCS     = null;
            OleDbCommand    ocmdPCS     = null;

            try
            {
                string strSql = "SELECT ISNULL(MAX("
                                + sys_ReportAndGroupTable.REPORTORDER_FLD + "),0)"
                                + " FROM  " + sys_ReportAndGroupTable.TABLE_NAME
                                + " WHERE " + sys_ReportAndGroupTable.GROUPID_FLD + " = ? ";        // + pstrGroupID + "'";

                DataAccess.Utils utils = new DataAccess.Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);

                ocmdPCS = new OleDbCommand(strSql, oconPCS);
                ocmdPCS.Parameters.Add(new OleDbParameter(sys_ReportAndGroupTable.GROUPID_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[sys_ReportAndGroupTable.GROUPID_FLD].Value = pstrGroupID;
                ocmdPCS.Connection.Open();

                // return the max order
                return(int.Parse(ocmdPCS.ExecuteScalar().ToString().Trim()));
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }
            catch (FormatException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }
            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.INVALIDEXCEPTION, 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();
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pstrAddedRoleName"></param>
        public void InsertDefaultMenu(string pstrAddedRoleName)
        {
            const string METHOD_NAME = THIS + ".Delete()";
            string       strSql      = String.Empty;

            strSql = " INSERT INTO Sys_Right(RoleID,Menu_EntryID,Permission)"
                     + " SELECT RoleID,Menu_EntryID,1"
                     + " FROM (SELECT RoleID FROM Sys_Role WHERE Name IN (" + pstrAddedRoleName + ") ) Role,"
                     + " (SELECT DISTINCT "
                     + "A." + Sys_Menu_EntryTable.MENU_ENTRYID_FLD
                     + " FROM " + Sys_Menu_EntryTable.TABLE_NAME + " A "
                     + " INNER JOIN " + Sys_Menu_EntryTable.TABLE_NAME + " B "
                     + " ON A." + Sys_Menu_EntryTable.SHORTCUT_FLD + " = B." + Sys_Menu_EntryTable.PARENT_SHORTCUT_FLD
                     + " WHERE A." + Sys_Menu_EntryTable.TYPE_FLD + " IN (" + ((int)MenuTypeEnum.VisibleBoth).ToString() + "," + ((int)MenuTypeEnum.VisibleMenu).ToString() + ")"
                     + " AND B." + Sys_Menu_EntryTable.TYPE_FLD + " IN (" + ((int)MenuTypeEnum.VisibleBoth).ToString() + "," + ((int)MenuTypeEnum.VisibleMenu).ToString() + ")"
                     + " AND B." + Sys_Menu_EntryTable.PARENT_CHILD_FLD + " = " + ((int)MenuParentChildEnum.SpecialLeafMenu).ToString()
                     + " UNION "
                     + " SELECT " + Sys_Menu_EntryTable.MENU_ENTRYID_FLD
                     + " FROM " + Sys_Menu_EntryTable.TABLE_NAME
                     + " WHERE " + Sys_Menu_EntryTable.PARENT_CHILD_FLD + "=" + ((int)MenuParentChildEnum.SpecialLeafMenu).ToString() + ") Menu";
            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            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();
                    }
                }
            }
        }
Exemple #6
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to update a DataSet
        ///    </Description>
        ///    <Inputs>
        ///        DataSet
        ///    </Inputs>
        ///    <Outputs>
        ///
        ///    </Outputs>
        ///    <Returns>
        ///
        ///    </Returns>
        ///    <Authors>
        ///       Code Generate
        ///    </Authors>
        ///    <History>
        ///       Monday, January 17, 2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************

        public void UpdateDataSet(DataSet pdstData)
        {
            const string        METHOD_NAME = THIS + ".UpdateDataSet()";
            OleDbConnection     oconPCS     = null;
            OleDbCommandBuilder odcbPCS;
            OleDbDataAdapter    odadPCS = new OleDbDataAdapter();

            try
            {
                string strSql = " SELECT "
                                + Sys_RightTable.RIGHTID_FLD + ","
                                + Sys_RightTable.PERMISSION_FLD + ","
                                + Sys_RightTable.ROLEID_FLD + ","
                                + Sys_RightTable.MENU_ENTRYID_FLD +
                                " FROM " + Sys_RightTable.TABLE_NAME;
                DataAccess.Utils utils = new DataAccess.Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                odadPCS.SelectCommand = new OleDbCommand(strSql, oconPCS);
                odcbPCS = new OleDbCommandBuilder(odadPCS);
                pdstData.EnforceConstraints = false;
                odadPCS.Update(pdstData, Sys_RightTable.TABLE_NAME);
                pdstData.AcceptChanges();
                pdstData.Tables[Sys_RightTable.TABLE_NAME].Clear();
                odadPCS.Fill(pdstData.Tables[Sys_RightTable.TABLE_NAME]);
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.DUPLICATE_KEY, 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();
                    }
                }
            }
        }
Exemple #7
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get all data from Sys_Right
        ///    </Description>
        ///    <Inputs>
        ///
        ///    </Inputs>
        ///    <Outputs>
        ///       DataSet
        ///    </Outputs>
        ///    <Returns>
        ///       DataSet
        ///    </Returns>
        ///    <Authors>
        ///       Code Generate
        ///    </Authors>
        ///    <History>
        ///       Monday, January 17, 2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************

        public DataSet List()
        {
            const string METHOD_NAME = THIS + ".List()";
            DataSet      dstPCS      = new DataSet();



            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                string strSql = String.Empty;

                strSql = "SELECT "
                         + Sys_RightTable.RIGHTID_FLD + ","
                         + Sys_RightTable.PERMISSION_FLD + ","
                         + Sys_RightTable.ROLEID_FLD + ","
                         + Sys_RightTable.MENU_ENTRYID_FLD
                         + " FROM " + Sys_RightTable.TABLE_NAME;
                DataAccess.Utils utils = new DataAccess.Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSql, oconPCS);
                ocmdPCS.Connection.Open();

                OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
                odadPCS.Fill(dstPCS, Sys_RightTable.TABLE_NAME);

                return(dstPCS);
            }
            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();
                    }
                }
            }
        }
Exemple #8
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get all rights assigned to a role
        ///    </Description>
        ///    <Inputs>
        ///    pintRoleID
        ///    </Inputs>
        ///    <Outputs>
        ///
        ///    </Outputs>
        ///    <Returns>
        ///       number of row deleted
        ///    </Returns>
        ///    <Authors>
        ///       DuongNA
        ///    </Authors>
        ///    <History>
        ///       9/10/2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public int DeleteRightsOfRole(string pstrRoleIDs)
        {
            const string    METHOD_NAME = THIS + ".DeleteRightsOfRole()";
            OleDbConnection oconPCS     = null;
            OleDbCommand    ocmdPCS     = null;
            int             nRes        = 0;

            try
            {
                string strSql = string.Empty;
                strSql = "DELETE "
                         + Sys_RightTable.TABLE_NAME
                         + " WHERE " + Sys_RightTable.ROLEID_FLD + " IN (" + pstrRoleIDs + ")";

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

                nRes = ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME, ex);
            }

            catch (InvalidOperationException ex)
            {
                throw new PCSDBException(ErrorCode.INVALIDEXCEPTION, 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();
                    }
                }
            }
            return(nRes);
        }
Exemple #9
0
        public int GetMaxValue(string pstrTableName, string pstrColumnName)
        {
            const string METHOD_NAME = THIS + ".GetMaxValue()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;
            string          strSql  = String.Empty;

            strSql = " SELECT isnull(max( " + pstrColumnName + "),0) " +
                     " FROM " + pstrTableName;
            try
            {
                DataAccess.Utils utils = new DataAccess.Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSql, oconPCS);
                ocmdPCS.Connection.Open();

                string strMaxValue = ocmdPCS.ExecuteScalar().ToString();

                try
                {
                    return(int.Parse(strMaxValue));
                }
                catch
                {
                    return(0);
                }
            }
            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();
                    }
                }
            }
        }
Exemple #10
0
        public DataSet List(string strSqlStatement, string strTableName)
        {
            const string METHOD_NAME = THIS + ".List()";
            const string BASE_TABLE  = "BASE TABLE";
            DataSet      dstPCS      = new DataSet();



            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                strSqlStatement += "; SELECT TABLE_TYPE from INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '" + strTableName + "'";
                DataAccess.Utils utils = new DataAccess.Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSqlStatement, oconPCS);
                ocmdPCS.Connection.Open();

                OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
                odadPCS.Fill(dstPCS, strTableName);
                if (dstPCS.Tables[1].Rows[0]["TABLE_TYPE"].ToString().ToUpper().Trim() == BASE_TABLE)
                {
                    odadPCS.FillSchema(dstPCS.Tables[strTableName], SchemaType.Mapped);
                }
                return(dstPCS);
            }
            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();
                    }
                }
            }
        }
Exemple #11
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to delete data from Sys_Right
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       void
        ///    </Outputs>
        ///    <Returns>
        ///
        ///    </Returns>
        ///    <Authors>
        ///       Code generate
        ///    </Authors>
        ///    <History>
        ///       09-Dec-2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************

        public void Delete(int pintID)
        {
            const string METHOD_NAME = THIS + ".Delete()";
            string       strSql      = String.Empty;

            strSql = "DELETE " + Sys_RightTable.TABLE_NAME + " WHERE  " + "RightID" + "=" + pintID.ToString();
            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
                ocmdPCS = null;
            }
            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();
                    }
                }
            }
        }
Exemple #12
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get the min order of row in sys_tablegroup
        ///    </Description>
        ///    <Inputs>
        ///        N/A
        ///    </Inputs>
        ///    <Outputs>
        ///      position minimum of row
        ///    </Outputs>
        ///    <Returns>
        ///       int
        ///    </Returns>
        ///    <Authors>
        ///       NgocHT
        ///    </Authors>
        ///    <History>
        ///       30-Dec-2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public int MinGroupOrder()
        {
            const string METHOD_NAME = THIS + ".GroupOrder()";
            string       strSql;

            strSql = "SELECT ISNULL (MIN(" + sys_TableGroupTable.GROUPORDER_FLD + "),0) FROM   " +
                     sys_TableGroupTable.TABLE_NAME;

            int             min;
            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                ocmdPCS.Connection.Open();
                min = int.Parse(ocmdPCS.ExecuteScalar().ToString());
                return(min);
            }
            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();
                    }
                }
            }
        }
Exemple #13
0
        public void UpdateDataSet(DataSet pData, string strSql, bool blnForEdit, string strSqlEdit)
        {
            const string METHOD_NAME = THIS + ".UpdateDataSet()";

            OleDbConnection     oconPCS = null;
            OleDbCommandBuilder odcbPCS;
            OleDbDataAdapter    odadPCS = new OleDbDataAdapter();

            try
            {
                DataAccess.Utils utils = new DataAccess.Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                oconPCS.Open();
                odadPCS.SelectCommand = new OleDbCommand(strSql, oconPCS);
                odcbPCS = new OleDbCommandBuilder(odadPCS);

                //string strXX1 = odcbPCS.GetDeleteCommand().CommandText;
                //string strXX2 = odcbPCS.GetUpdateCommand().CommandText;
                //string strXX3 = odcbPCS.GetInsertCommand().CommandText;

                pData.EnforceConstraints = false;

                odadPCS.Update(pData, pData.Tables[0].TableName);

                pData.Clear();
                if (blnForEdit)
                {
                    odadPCS.SelectCommand.CommandText = strSqlEdit;
                    odadPCS.SelectCommand.CommandType = CommandType.Text;
                }
                odadPCS.Fill(pData, pData.Tables[0].TableName);
                pData.AcceptChanges();
            }
            catch (OleDbException ex)
            {
                if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE ||
                    ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_UNIQUE_KEYCODE)
                {
                    throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);
                }
                else if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
                {
                    throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);
                }
                else if (ex.Errors[1].NativeError == ErrorCode.SQLDBNULL_VIALATION_KEYCODE)
                {
                    //515 - Null data vialation
                    throw new PCSDBException(ErrorCode.DBNULL_VIALATION, 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();
                    }
                }
            }
        }