コード例 #1
0
        ///    <summary>
        ///       This method uses to add data to Sys_VisibleControl
        ///    </summary>
        ///    <Inputs>
        ///        Sys_VisibleControlVO
        ///    </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_VisibleControlVO objObject = (Sys_VisibleControlVO)pobjObjectVO;
                string strSql = String.Empty;
                Utils  utils  = new Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand("", oconPCS);

                strSql = "INSERT INTO Sys_VisibleControl("
                         + Sys_VisibleControlTable.FORMNAME_FLD + ","
                         + Sys_VisibleControlTable.CONTROLNAME_FLD + ","
                         + Sys_VisibleControlTable.SUBCONTROLNAME_FLD + ","
                         + Sys_VisibleControlTable.CONTROLGROUPID_FLD + ")"
                         + "VALUES(?,?,?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_VisibleControlTable.FORMNAME_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_VisibleControlTable.FORMNAME_FLD].Value = objObject.FormName;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_VisibleControlTable.CONTROLNAME_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_VisibleControlTable.CONTROLNAME_FLD].Value = objObject.ControlName;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_VisibleControlTable.SUBCONTROLNAME_FLD, OleDbType.VarWChar));
                ocmdPCS.Parameters[Sys_VisibleControlTable.SUBCONTROLNAME_FLD].Value = objObject.SubControlName;

                ocmdPCS.Parameters.Add(new OleDbParameter(Sys_VisibleControlTable.CONTROLGROUPID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[Sys_VisibleControlTable.CONTROLGROUPID_FLD].Value = objObject.ControlGroupID;



                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_VisibleControl
        ///    </summary>
        ///    <Inputs>
        ///        Sys_VisibleControlVO
        ///    </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_VisibleControlTable.VISIBLECONTROLID_FLD + ","
                         + Sys_VisibleControlTable.FORMNAME_FLD + ","
                         + Sys_VisibleControlTable.CONTROLNAME_FLD + ","
                         + Sys_VisibleControlTable.SUBCONTROLNAME_FLD + ","
                         + Sys_VisibleControlTable.CONTROLGROUPID_FLD
                         + " FROM " + Sys_VisibleControlTable.TABLE_NAME
                         + " WHERE " + Sys_VisibleControlTable.VISIBLECONTROLID_FLD + "=" + pintID;

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

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

                Sys_VisibleControlVO objObject = new Sys_VisibleControlVO();

                while (odrPCS.Read())
                {
                    objObject.VisibleControlID = int.Parse(odrPCS[Sys_VisibleControlTable.VISIBLECONTROLID_FLD].ToString().Trim());
                    objObject.FormName         = odrPCS[Sys_VisibleControlTable.FORMNAME_FLD].ToString().Trim();
                    objObject.ControlName      = odrPCS[Sys_VisibleControlTable.CONTROLNAME_FLD].ToString().Trim();
                    objObject.SubControlName   = odrPCS[Sys_VisibleControlTable.SUBCONTROLNAME_FLD].ToString().Trim();
                    objObject.ControlGroupID   = int.Parse(odrPCS[Sys_VisibleControlTable.CONTROLGROUPID_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();
                    }
                }
            }
        }