예제 #1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from sys_TableGroup
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       sys_TableGroupVO
        ///    </Outputs>
        ///    <Returns>
        ///       sys_TableGroupVO
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Monday, December 27, 2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************

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

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

            try
            {
                string strSql = String.Empty;
                strSql = "SELECT "
                         + sys_TableGroupTable.TABLEGROUPID_FLD + ","
                         + sys_TableGroupTable.CODE_FLD + ","
                         + sys_TableGroupTable.TABLEGROUPNAME_FLD + ","
                         + sys_TableGroupTable.GROUPORDER_FLD
                         + " FROM " + sys_TableGroupTable.TABLE_NAME
                         + " WHERE " + sys_TableGroupTable.TABLEGROUPID_FLD + "=" + pintID;

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

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

                sys_TableGroupVO objObject = new sys_TableGroupVO();

                while (odrPCS.Read())
                {
                    objObject.TableGroupID   = int.Parse(odrPCS[sys_TableGroupTable.TABLEGROUPID_FLD].ToString());
                    objObject.Code           = odrPCS[sys_TableGroupTable.CODE_FLD].ToString();
                    objObject.TableGroupName = odrPCS[sys_TableGroupTable.TABLEGROUPNAME_FLD].ToString();
                    objObject.GroupOrder     = int.Parse(odrPCS[sys_TableGroupTable.GROUPORDER_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();
                    }
                }
            }
        }
예제 #2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get rows in sys_tablegroup
        ///    </Description>
        ///    <Inputs>
        ///        N/A
        ///    </Inputs>
        ///    <Outputs>
        ///      row
        ///    </Outputs>
        ///    <Returns>
        ///       array
        ///    </Returns>
        ///    <Authors>
        ///       NgocHT
        ///    </Authors>
        ///    <History>
        ///       29-Dec-2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public ArrayList GetObjectVOs()
        {
            ArrayList    arrObjects  = new ArrayList();
            const string METHOD_NAME = THIS + ".GetObjectVOs()";
            DataSet      dstPCS      = new DataSet();
            string       strSql      = "SELECT  "
                                       + sys_TableGroupTable.TABLEGROUPID_FLD
                                       + "," + sys_TableGroupTable.CODE_FLD
                                       + "," + sys_TableGroupTable.TABLEGROUPNAME_FLD
                                       + "," + sys_TableGroupTable.GROUPORDER_FLD
                                       + " FROM " + sys_TableGroupTable.TABLE_NAME
                                       + " ORDER BY " + sys_TableGroupTable.GROUPORDER_FLD;

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

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

                ocmdPCS.Connection.Open();
                odrPCS = ocmdPCS.ExecuteReader();
                while (odrPCS.Read())
                {
                    sys_TableGroupVO objGroupVO = new sys_TableGroupVO();
                    objGroupVO.TableGroupID   = int.Parse(odrPCS[sys_TableGroupTable.TABLEGROUPID_FLD].ToString());
                    objGroupVO.Code           = odrPCS[sys_TableGroupTable.CODE_FLD].ToString();
                    objGroupVO.TableGroupName = odrPCS[sys_TableGroupTable.TABLEGROUPNAME_FLD].ToString();
                    objGroupVO.GroupOrder     = int.Parse(odrPCS[sys_TableGroupTable.GROUPORDER_FLD].ToString());

                    arrObjects.Add(objGroupVO);
                }
                return(arrObjects);
            }
            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_TableGroup
        ///    </Description>
        ///    <Inputs>
        ///       sys_TableGroupVO
        ///    </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_TableGroupVO objObject = (sys_TableGroupVO)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_TableGroupTable.TABLE_NAME + " SET "
                          + sys_TableGroupTable.CODE_FLD + "=   ?" + ","
                          + sys_TableGroupTable.TABLEGROUPNAME_FLD + "=   ?" + ","
                          + sys_TableGroupTable.GROUPORDER_FLD + "=  ?"
                          + " WHERE " + sys_TableGroupTable.TABLEGROUPID_FLD + "= ?";

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableGroupTable.CODE_FLD, OleDbType.Char));
                ocmdPCS.Parameters[sys_TableGroupTable.CODE_FLD].Value = objObject.Code;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableGroupTable.TABLEGROUPNAME_FLD, OleDbType.Char));
                ocmdPCS.Parameters[sys_TableGroupTable.TABLEGROUPNAME_FLD].Value = objObject.TableGroupName;

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

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableGroupTable.TABLEGROUPID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[sys_TableGroupTable.TABLEGROUPID_FLD].Value = objObject.TableGroupID;


                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            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
                {
                    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
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add data to sys_TableGroup
        ///    </Description>
        ///    <Inputs>
        ///        sys_TableGroupVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Monday, December 27, 2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************


        public int AddGroupAndReturnID(object pobjObjectVO)
        {
            const string METHOD_NAME = THIS + ".Add()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO " + sys_TableGroupTable.TABLE_NAME + " ("
                         + sys_TableGroupTable.CODE_FLD + ","
                         + sys_TableGroupTable.TABLEGROUPNAME_FLD + ","
                         + sys_TableGroupTable.GROUPORDER_FLD + ")"
                         + "VALUES(?,?,?); Select @@IDENTITY as NewID ";

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableGroupTable.CODE_FLD, OleDbType.Char));
                ocmdPCS.Parameters[sys_TableGroupTable.CODE_FLD].Value = objObject.Code;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableGroupTable.TABLEGROUPNAME_FLD, OleDbType.Char));
                ocmdPCS.Parameters[sys_TableGroupTable.TABLEGROUPNAME_FLD].Value = objObject.TableGroupName;

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



                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                return(int.Parse(ocmdPCS.ExecuteScalar().ToString()));
            }
            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
                {
                    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();
                    }
                }
            }
        }