Ejemplo n.º 1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from sys_RoleWC
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       sys_RoleWCVO
        ///    </Outputs>
        ///    <Returns>
        ///       sys_RoleWCVO
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Wednesday, November 16, 2005
        ///    </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_RoleWCTable.ROLEWCID_FLD + ","
                         + sys_RoleWCTable.ROLEID_FLD + ","
                         + sys_RoleWCTable.WORKCENTERID_FLD
                         + " FROM " + sys_RoleWCTable.TABLE_NAME
                         + " WHERE " + sys_RoleWCTable.ROLEWCID_FLD + "=" + pintID;

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

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

                sys_RoleWCVO objObject = new sys_RoleWCVO();

                while (odrPCS.Read())
                {
                    objObject.RoleWCID     = int.Parse(odrPCS[sys_RoleWCTable.ROLEWCID_FLD].ToString().Trim());
                    objObject.RoleID       = int.Parse(odrPCS[sys_RoleWCTable.ROLEID_FLD].ToString().Trim());
                    objObject.WorkCenterID = int.Parse(odrPCS[sys_RoleWCTable.WORKCENTERID_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();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add data to sys_RoleWC
        ///    </Description>
        ///    <Inputs>
        ///        sys_RoleWCVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Wednesday, November 16, 2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************


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

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO sys_RoleWC("
                         + sys_RoleWCTable.ROLEID_FLD + ","
                         + sys_RoleWCTable.WORKCENTERID_FLD + ")"
                         + "VALUES(?,?)";

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

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_RoleWCTable.WORKCENTERID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[sys_RoleWCTable.WORKCENTERID_FLD].Value = objObject.WorkCenterID;



                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                ocmdPCS.ExecuteNonQuery();
            }
            catch (OleDbException ex)
            {
                if (ex.Errors.Count > 1)
                {
                    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();
                    }
                }
            }
        }