コード例 #1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to update data to sys_Table
        ///    </Description>
        ///    <Inputs>
        ///       sys_TableVO
        ///    </Inputs>
        ///    <Outputs>
        ///
        ///    </Outputs>
        ///    <Returns>
        ///
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       29-Dec-2004
        ///    </History>
        ///    <Notes>
        ///			Modified by NgocHT
        ///    </Notes>
        //**************************************************************************
        public void Update(object pobjObjecVO)
        {
            const string METHOD_NAME = THIS + ".Update()";

            sys_TableVO objObject = (sys_TableVO)pobjObjecVO;

            //prepare value for parameters
            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                string strSql = string.Empty;
                strSql = "UPDATE " + sys_TableTable.TABLE_NAME + " SET "
                         + sys_TableTable.CODE_FLD + "=   ?" + ","
                         + sys_TableTable.TABLENAME_FLD + "=   ?" + ","
                         + sys_TableTable.TABLEORVIEW_FLD + "=   ?" + ","
                         + sys_TableTable.ISVIEWONLY_FLD + "=   ?" + ","
                         + sys_TableTable.HEIGHT_FLD + "=  ?"
                         + " WHERE " + sys_TableTable.TABLEID_FLD + "= ?";

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

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

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.TABLENAME_FLD, OleDbType.VarChar));
                ocmdPCS.Parameters[sys_TableTable.TABLENAME_FLD].Value = objObject.TableName;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.TABLEORVIEW_FLD, OleDbType.VarChar));
                ocmdPCS.Parameters[sys_TableTable.TABLEORVIEW_FLD].Value = objObject.TableOrView;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.ISVIEWONLY_FLD, OleDbType.Boolean));
                ocmdPCS.Parameters[sys_TableTable.ISVIEWONLY_FLD].Value = objObject.IsViewOnly;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.HEIGHT_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[sys_TableTable.HEIGHT_FLD].Value = objObject.Height;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.TABLEID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[sys_TableTable.TABLEID_FLD].Value = objObject.TableID;


                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();
                    }
                }
            }
        }
コード例 #2
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add data to sys_Table
        ///    </Description>
        ///    <Inputs>
        ///        sys_TableVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Monday, December 27, 2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public void Add(object pobjObjectVO)
        {
            const string METHOD_NAME = THIS + ".Add()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

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

                strSql = "INSERT INTO " + sys_TableTable.TABLE_NAME + " ("
                         + sys_TableTable.CODE_FLD + ","
                         + sys_TableTable.TABLENAME_FLD + ","
                         + sys_TableTable.TABLEORVIEW_FLD + ","
                         + sys_TableTable.HEIGHT_FLD + ")"
                         + "VALUES(?,?,?,?)";

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

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.TABLENAME_FLD, OleDbType.VarChar));
                ocmdPCS.Parameters[sys_TableTable.TABLENAME_FLD].Value = objObject.TableName;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.TABLEORVIEW_FLD, OleDbType.VarChar));
                ocmdPCS.Parameters[sys_TableTable.TABLEORVIEW_FLD].Value = objObject.TableOrView;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.HEIGHT_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[sys_TableTable.HEIGHT_FLD].Value = objObject.Height;


                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();
                    }
                }
            }
        }
コード例 #3
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get data from sys_Table
        ///    </Description>
        ///    <Inputs>
        ///        ID
        ///    </Inputs>
        ///    <Outputs>
        ///       sys_TableVO
        ///    </Outputs>
        ///    <Returns>
        ///       sys_TableVO
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Monday, December 27, 2004
        ///    </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_TableTable.TABLEID_FLD + ","
                         + sys_TableTable.CODE_FLD + ","
                         + sys_TableTable.TABLENAME_FLD + ","
                         + sys_TableTable.TABLEORVIEW_FLD + ","
                         + sys_TableTable.HEIGHT_FLD
                         + " FROM " + sys_TableTable.TABLE_NAME
                         + " WHERE " + sys_TableTable.TABLEID_FLD + "=" + pintID;

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

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

                sys_TableVO objObject = new sys_TableVO();

                while (odrPCS.Read())
                {
                    objObject.TableID     = int.Parse(odrPCS[sys_TableTable.TABLEID_FLD].ToString());
                    objObject.Code        = odrPCS[sys_TableTable.CODE_FLD].ToString().Trim();
                    objObject.TableName   = odrPCS[sys_TableTable.TABLENAME_FLD].ToString().Trim();
                    objObject.TableOrView = odrPCS[sys_TableTable.TABLEORVIEW_FLD].ToString().Trim();
                    if (odrPCS[sys_TableTable.HEIGHT_FLD] != DBNull.Value)
                    {
                        objObject.Height = int.Parse(odrPCS[sys_TableTable.HEIGHT_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();
                    }
                }
            }
        }
コード例 #4
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to add a new Row into the sys_Table
        ///       and then a new row with newest TableId into the sys_TableAndGroup
        ///    </Description>
        ///    <Inputs>
        ///        sys_TableVO
        ///        GroupID
        ///    </Inputs>
        ///    <Outputs>
        ///       a new row is inserted into the sys_Table
        ///       and a new row is inserted into the sys_TableAndGroup
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Monday, December 27, 2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        public int AddTableAndReturnMaxID(object pobjObjectVO, int pintGroupID)
        {
            const string METHOD_NAME = THIS + ".AddTableAndReturnMaxID()";

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                //Get the highest table order
                int intTableOrder = MaxTableOrder(pintGroupID) + 1;

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

                strSql = "INSERT INTO  " + sys_TableTable.TABLE_NAME + " ("
                         + sys_TableTable.CODE_FLD + ","
                         + sys_TableTable.TABLENAME_FLD + ","
                         + sys_TableTable.TABLEORVIEW_FLD + ","
                         + sys_TableTable.ISVIEWONLY_FLD + ","
                         + sys_TableTable.HEIGHT_FLD + ")"
                         + "VALUES(?,?,?,?,?)";

                //This query will be used to get the latest identity value
                strSql += "; SELECT @@IDENTITY as MaxID";

                //; Insert into sys_TableAndGroup
                strSql += " ; INSERT INTO " + sys_TableAndGroupTable.TABLE_NAME + " ("
                          + sys_TableAndGroupTable.TABLEGROUPID_FLD + ","
                          + sys_TableAndGroupTable.TABLEID_FLD + ","
                          + sys_TableAndGroupTable.TABLEORDER_FLD + ")"
                          + "VALUES(" + pintGroupID + " ,@@IDENTITY," + intTableOrder + ")";


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

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.TABLENAME_FLD, OleDbType.Char));
                ocmdPCS.Parameters[sys_TableTable.TABLENAME_FLD].Value = objObject.TableName;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.TABLEORVIEW_FLD, OleDbType.Char));
                ocmdPCS.Parameters[sys_TableTable.TABLEORVIEW_FLD].Value = objObject.TableOrView;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.ISVIEWONLY_FLD, OleDbType.Boolean));
                ocmdPCS.Parameters[sys_TableTable.ISVIEWONLY_FLD].Value = objObject.IsViewOnly;

                ocmdPCS.Parameters.Add(new OleDbParameter(sys_TableTable.HEIGHT_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[sys_TableTable.HEIGHT_FLD].Value = objObject.Height;


                ocmdPCS.CommandText = strSql;
                ocmdPCS.Connection.Open();
                //ocmdPCS.ExecuteNonQuery();
                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();
                    }
                }
            }
        }