コード例 #1
0
        /// <summary>
        /// Gets period by to date
        /// </summary>
        /// <param name="pdtmToDate">To Date of Period</param>
        /// <returns>CST_ActCostAllocationMasterVO object</returns>
        public object GetObjectVO(DateTime pdtmToDate)
        {
            const string METHOD_NAME = THIS + ".GetObjectVO()";

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

            try
            {
                string strSql = String.Empty;
                strSql = "SELECT TOP 1 "
                         + CST_ActCostAllocationMasterTable.ACTCOSTALLOCATIONMASTERID_FLD + ","
                         + CST_ActCostAllocationMasterTable.PERIODNAME_FLD + ","
                         + CST_ActCostAllocationMasterTable.FROMDATE_FLD + ","
                         + CST_ActCostAllocationMasterTable.TODATE_FLD + ","
                         + CST_ActCostAllocationMasterTable.CCNID_FLD + ","
                         + CST_ActCostAllocationMasterTable.CURRENCYID_FLD + ","
                         + CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD
                         + " FROM " + CST_ActCostAllocationMasterTable.TABLE_NAME
                         + " WHERE " + CST_ActCostAllocationMasterTable.TODATE_FLD + "< ?"
                         + " ORDER BY " + CST_ActCostAllocationMasterTable.TODATE_FLD + " DESC";

                Utils utils = new Utils();
                oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
                ocmdPCS = new OleDbCommand(strSql, oconPCS);
                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.TODATE_FLD, OleDbType.Date)).Value = pdtmToDate;

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

                CST_ActCostAllocationMasterVO objObject = new CST_ActCostAllocationMasterVO();

                if (odrPCS.Read())
                {
                    objObject.ActCostAllocationMasterID = int.Parse(odrPCS[CST_ActCostAllocationMasterTable.ACTCOSTALLOCATIONMASTERID_FLD].ToString().Trim());
                    objObject.PeriodName = odrPCS[CST_ActCostAllocationMasterTable.PERIODNAME_FLD].ToString().Trim();
                    objObject.FromDate   = DateTime.Parse(odrPCS[CST_ActCostAllocationMasterTable.FROMDATE_FLD].ToString().Trim());
                    objObject.ToDate     = DateTime.Parse(odrPCS[CST_ActCostAllocationMasterTable.TODATE_FLD].ToString().Trim());
                    objObject.CCNID      = int.Parse(odrPCS[CST_ActCostAllocationMasterTable.CCNID_FLD].ToString().Trim());
                    objObject.CurrencyID = int.Parse(odrPCS[CST_ActCostAllocationMasterTable.CURRENCYID_FLD].ToString().Trim());
                    if (!odrPCS[CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD].Equals(DBNull.Value))
                    {
                        objObject.RollupDate = DateTime.Parse(odrPCS[CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD].ToString().Trim());
                    }
                    else
                    {
                        objObject.RollupDate = DateTime.MinValue;
                    }

                    return(objObject);
                }

                return(null);
            }
            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 update data to CST_ActCostAllocationMaster
        ///    </Description>
        ///    <Inputs>
        ///       CST_ActCostAllocationMasterVO
        ///    </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()";

            CST_ActCostAllocationMasterVO objObject = (CST_ActCostAllocationMasterVO)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 CST_ActCostAllocationMaster SET "
                          + CST_ActCostAllocationMasterTable.PERIODNAME_FLD + "=   ?" + ","
                          + CST_ActCostAllocationMasterTable.FROMDATE_FLD + "=   ?" + ","
                          + CST_ActCostAllocationMasterTable.TODATE_FLD + "=   ?" + ","
                          + CST_ActCostAllocationMasterTable.CCNID_FLD + "=   ?" + ","
                          + CST_ActCostAllocationMasterTable.CURRENCYID_FLD + "=   ?" + ","
                          + CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD + "=  ?"
                          + " WHERE " + CST_ActCostAllocationMasterTable.ACTCOSTALLOCATIONMASTERID_FLD + "= ?";

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.PERIODNAME_FLD, OleDbType.WChar));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.PERIODNAME_FLD].Value = objObject.PeriodName;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.FROMDATE_FLD, OleDbType.Date));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.FROMDATE_FLD].Value = objObject.FromDate;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.TODATE_FLD, OleDbType.Date));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.TODATE_FLD].Value = objObject.ToDate;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.CCNID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.CCNID_FLD].Value = objObject.CCNID;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.CURRENCYID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.CURRENCYID_FLD].Value = objObject.CurrencyID;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD, OleDbType.Date));
                if (objObject.RollupDate != DateTime.MinValue)
                {
                    ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD].Value = objObject.RollupDate;
                }
                else
                {
                    ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD].Value = DBNull.Value;
                }

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.ACTCOSTALLOCATIONMASTERID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.ACTCOSTALLOCATIONMASTERID_FLD].Value = objObject.ActCostAllocationMasterID;


                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();
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// If
        /// SELECT FROM MTR_ACDSOptionDetailDS WHERE (pobjMasterVO.FromDate between FromDate, ToDate) OR (pobjMasterVO.ToDate between FromDate, ToDate)
        /// return >= 1 row then return False
        /// else return True
        /// </summary>
        public bool IsPeriodOverlap(object pobjMasterVO)
        {
            const string METHOD_NAME = THIS + ".IsPeriodOverlap()";

            //Cast to CST_ActCostAllocationMasterVO object
            CST_ActCostAllocationMasterVO voMaster = (CST_ActCostAllocationMasterVO)pobjMasterVO;

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                string strSql = String.Empty;

                strSql = "SELECT Count(*) "
                         + " FROM " + CST_ActCostAllocationMasterTable.TABLE_NAME
                         + " WHERE (" + CST_ActCostAllocationMasterTable.ACTCOSTALLOCATIONMASTERID_FLD + " <> " + voMaster.ActCostAllocationMasterID + ") "
                         + " AND ((" + CST_ActCostAllocationMasterTable.FROMDATE_FLD + " BETWEEN '" + voMaster.FromDate.ToString("yyyy-MM-dd") + "' AND '" + voMaster.ToDate.ToString("yyyy-MM-dd") + "')"
                         + " OR (" + CST_ActCostAllocationMasterTable.TODATE_FLD + " BETWEEN '" + voMaster.FromDate.ToString("yyyy-MM-dd") + "' AND '" + voMaster.ToDate.ToString("yyyy-MM-dd") + "')"
                         + " OR ('" + voMaster.FromDate.ToString("yyyy-MM-dd") + "' BETWEEN " + CST_ActCostAllocationMasterTable.FROMDATE_FLD + " AND " + CST_ActCostAllocationMasterTable.TODATE_FLD + ")"
                         + " OR ('" + voMaster.ToDate.ToString("yyyy-MM-dd") + "' BETWEEN " + CST_ActCostAllocationMasterTable.FROMDATE_FLD + " AND " + CST_ActCostAllocationMasterTable.TODATE_FLD + "))";

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

                object objReturn = ocmdPCS.ExecuteScalar();
                if (objReturn == null)
                {
                    return(false);
                }
                else
                {
                    if (int.Parse(objReturn.ToString()) > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            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 data to CST_ActCostAllocationMaster
        ///    </Description>
        ///    <Inputs>
        ///        CST_ActCostAllocationMasterVO
        ///    </Inputs>
        ///    <Outputs>
        ///       newly inserted primarkey value
        ///    </Outputs>
        ///    <Returns>
        ///       void
        ///    </Returns>
        ///    <Authors>
        ///       HungLa
        ///    </Authors>
        ///    <History>
        ///       Tuesday, February 21, 2006
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************


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

            OleDbConnection oconPCS = null;
            OleDbCommand    ocmdPCS = null;

            try
            {
                CST_ActCostAllocationMasterVO objObject = (CST_ActCostAllocationMasterVO)pobjObjectVO;

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

                strSql = "INSERT INTO CST_ActCostAllocationMaster("
                         + CST_ActCostAllocationMasterTable.PERIODNAME_FLD + ","
                         + CST_ActCostAllocationMasterTable.FROMDATE_FLD + ","
                         + CST_ActCostAllocationMasterTable.TODATE_FLD + ","
                         + CST_ActCostAllocationMasterTable.CCNID_FLD + ","
                         + CST_ActCostAllocationMasterTable.CURRENCYID_FLD + ","
                         + CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD + ")"
                         + "VALUES(?,?,?,?,?,?)";

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.PERIODNAME_FLD, OleDbType.WChar));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.PERIODNAME_FLD].Value = objObject.PeriodName;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.FROMDATE_FLD, OleDbType.Date));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.FROMDATE_FLD].Value = objObject.FromDate;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.TODATE_FLD, OleDbType.Date));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.TODATE_FLD].Value = objObject.ToDate;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.CCNID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.CCNID_FLD].Value = objObject.CCNID;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.CURRENCYID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.CURRENCYID_FLD].Value = objObject.CurrencyID;

                ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD, OleDbType.Date));
                ocmdPCS.Parameters[CST_ActCostAllocationMasterTable.ROLLUPDATE_FLD].Value = objObject.RollupDate;



                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();
                    }
                }
            }
        }