Ejemplo n.º 1
0
        public void Update(object pobjObjecVO)
        {
            const string METHOD_NAME = THIS + ".Update()";

            cst_FreightDetailVO objObject = (cst_FreightDetailVO)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_FreightDetail SET "
                          + cst_FreightDetailTable.QUANTITY_FLD + "=   ?" + ","
                          + cst_FreightDetailTable.UNITPRICECIF_FLD + "=   ?" + ","
                          + cst_FreightDetailTable.AMOUNT_FLD + "=   ?" + ","
                          + cst_FreightDetailTable.FREIGHTMASTERID_FLD + "=   ?" + ","
                          + cst_FreightDetailTable.PRODUCTID_FLD + "=   ?" + ","
                          + cst_FreightDetailTable.BUYINGUMID_FLD + "=   ?" + ","
                          + cst_FreightDetailTable.RETURNTOVENDORDETAILID_FLD + "=   ?" + ","
                          // 12-05-2006 dungla: removed in order to compliable
                          //+ cst_FreightDetailTable.LINE_FLD + "=   ?" + ","
                          + cst_FreightDetailTable.VATAMOUNT_FLD + "=  ?"
                          + " WHERE " + cst_FreightDetailTable.FREIGHTDETAILID_FLD + "= ?";

                ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.QUANTITY_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[cst_FreightDetailTable.QUANTITY_FLD].Value = objObject.Quantity;

                ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.UNITPRICECIF_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[cst_FreightDetailTable.UNITPRICECIF_FLD].Value = objObject.UnitPriceCIF;

                ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.AMOUNT_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[cst_FreightDetailTable.AMOUNT_FLD].Value = objObject.Amount;

                ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.FREIGHTMASTERID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[cst_FreightDetailTable.FREIGHTMASTERID_FLD].Value = objObject.FreightMasterID;

                ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.PRODUCTID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[cst_FreightDetailTable.PRODUCTID_FLD].Value = objObject.ProductID;

                ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.BUYINGUMID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[cst_FreightDetailTable.BUYINGUMID_FLD].Value = objObject.BuyingUMID;

                // 12-05-2006 dungla: removed in order to compliable
//				ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.LINE_FLD, OleDbType.Integer));
//				ocmdPCS.Parameters[cst_FreightDetailTable.LINE_FLD].Value = objObject.Line;

                ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.VATAMOUNT_FLD, OleDbType.Decimal));
                ocmdPCS.Parameters[cst_FreightDetailTable.VATAMOUNT_FLD].Value = objObject.VATAmount;

                ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.RETURNTOVENDORDETAILID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[cst_FreightDetailTable.RETURNTOVENDORDETAILID_FLD].Value = objObject.ReturnToVendorDetailID;

                ocmdPCS.Parameters.Add(new OleDbParameter(cst_FreightDetailTable.FREIGHTDETAILID_FLD, OleDbType.Integer));
                ocmdPCS.Parameters[cst_FreightDetailTable.FREIGHTDETAILID_FLD].Value = objObject.FreightDetailID;


                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();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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 "
                         + cst_FreightDetailTable.FREIGHTDETAILID_FLD + ","
                         + cst_FreightDetailTable.RETURNTOVENDORDETAILID_FLD + ","
                         + cst_FreightDetailTable.QUANTITY_FLD + ","
                         + cst_FreightDetailTable.UNITPRICECIF_FLD + ","
                         + cst_FreightDetailTable.AMOUNT_FLD + ","
                         + cst_FreightDetailTable.FREIGHTMASTERID_FLD + ","
                         + cst_FreightDetailTable.PRODUCTID_FLD + ","
                         + cst_FreightDetailTable.BUYINGUMID_FLD + ","
                         // 12-05-2006 dungla: removed in order to compliable
                         //+ cst_FreightDetailTable.LINE_FLD + ","
                         + cst_FreightDetailTable.VATAMOUNT_FLD
                         + " FROM " + cst_FreightDetailTable.TABLE_NAME
                         + " WHERE " + cst_FreightDetailTable.FREIGHTDETAILID_FLD + "=" + pintID;

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

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

                cst_FreightDetailVO objObject = new cst_FreightDetailVO();

                while (odrPCS.Read())
                {
                    objObject.FreightDetailID = int.Parse(odrPCS[cst_FreightDetailTable.FREIGHTDETAILID_FLD].ToString().Trim());
                    objObject.Quantity        = Decimal.Parse(odrPCS[cst_FreightDetailTable.QUANTITY_FLD].ToString().Trim());
                    objObject.UnitPriceCIF    = Decimal.Parse(odrPCS[cst_FreightDetailTable.UNITPRICECIF_FLD].ToString().Trim());
                    objObject.Amount          = Decimal.Parse(odrPCS[cst_FreightDetailTable.AMOUNT_FLD].ToString().Trim());
                    objObject.FreightMasterID = int.Parse(odrPCS[cst_FreightDetailTable.FREIGHTMASTERID_FLD].ToString().Trim());
                    objObject.ProductID       = int.Parse(odrPCS[cst_FreightDetailTable.PRODUCTID_FLD].ToString().Trim());
                    objObject.BuyingUMID      = int.Parse(odrPCS[cst_FreightDetailTable.BUYINGUMID_FLD].ToString().Trim());
                    // 12-05-2006 dungla: removed in order to compliable
                    //objObject.Line = int.Parse(odrPCS[cst_FreightDetailTable.LINE_FLD].ToString().Trim());
                    objObject.VATAmount = Decimal.Parse(odrPCS[cst_FreightDetailTable.VATAMOUNT_FLD].ToString().Trim());
                    objObject.ReturnToVendorDetailID = int.Parse(odrPCS[cst_FreightDetailTable.RETURNTOVENDORDETAILID_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();
                    }
                }
            }
        }