コード例 #1
0
        ///    <summary>
        ///       This method uses to add data to Sys_ControlGroup
        ///    </summary>
        ///    <Inputs>
        ///        Sys_ControlGroupVO
        ///    </Inputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <History>
        ///       Monday, July 11, 2005
        ///    </History>


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

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO Sys_ControlGroup("
                         + Sys_ControlGroupTable.CONTROLGROUPTEXT_FLD + ")"
                         + "VALUES(?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_ControlGroupTable.CONTROLGROUPTEXT_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_ControlGroupTable.CONTROLGROUPTEXT_FLD].Value = objObject.ControlGroupText;



                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();
                    }
                }
            }
        }
コード例 #2
0
        ///    <summary>
        ///       This method uses to add data to Sys_ControlGroup
        ///    </summary>
        ///    <Inputs>
        ///        Sys_ControlGroupVO
        ///    </Inputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <History>
        ///       Monday, July 11, 2005
        ///    </History>

        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_ControlGroupTable.CONTROLGROUPID_FLD + ","
                         + Sys_ControlGroupTable.CONTROLGROUPTEXT_FLD
                         + " FROM " + Sys_ControlGroupTable.TABLE_NAME
                         + " WHERE " + Sys_ControlGroupTable.CONTROLGROUPID_FLD + "=" + pintID;

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

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

                Sys_ControlGroupVO objObject = new Sys_ControlGroupVO();

                while (odrPCS.Read())
                {
                    objObject.ControlGroupID   = int.Parse(odrPCS[Sys_ControlGroupTable.CONTROLGROUPID_FLD].ToString().Trim());
                    objObject.ControlGroupText = odrPCS[Sys_ControlGroupTable.CONTROLGROUPTEXT_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();
                    }
                }
            }
        }