//************************************************************************** /// <Description> /// This method uses to add data to PO_InvoiceDetail /// </Description> /// <Inputs> /// PO_InvoiceDetailVO /// </Inputs> /// <Outputs> /// newly inserted primarkey value /// </Outputs> /// <Returns> /// void /// </Returns> /// <Authors> /// HungLa /// </Authors> /// <History> /// Thursday, September 29, 2005 /// </History> /// <Notes> /// </Notes> //************************************************************************** public void Add(object pobjObjectVO) { const string METHOD_NAME = THIS + ".Add()"; OleDbConnection oconPCS = null; OleDbCommand ocmdPCS = null; try { PO_InvoiceDetailVO objObject = (PO_InvoiceDetailVO)pobjObjectVO; string strSql = String.Empty; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand("", oconPCS); strSql = "INSERT INTO PO_InvoiceDetail(" + PO_InvoiceDetailTable.INVOICELINE_FLD + "," + PO_InvoiceDetailTable.INVOICEMASTERID_FLD + "," + PO_InvoiceDetailTable.INVOICEQUANTITY_FLD + "," + PO_InvoiceDetailTable.UNITPRICE_FLD + "," + PO_InvoiceDetailTable.VAT_FLD + "," + PO_InvoiceDetailTable.VATAMOUNT_FLD + "," + PO_InvoiceDetailTable.IMPORTTAX_FLD + "," + PO_InvoiceDetailTable.IMPORTTAXAMOUNT_FLD + "," + PO_InvoiceDetailTable.INLAND_FLD + "," + PO_InvoiceDetailTable.BEFOREVATAMOUNT_FLD + "," + PO_InvoiceDetailTable.CIFAMOUNT_FLD + "," + PO_InvoiceDetailTable.CIPAMOUNT_FLD + "," + PO_InvoiceDetailTable.NOTE_FLD + "," + PO_InvoiceDetailTable.PRODUCTID_FLD + "," + PO_InvoiceDetailTable.PURCHASEORDERMASTERID_FLD + "," + PO_InvoiceDetailTable.PURCHASEORDERDETAILID_FLD + "," + PO_InvoiceDetailTable.DELIVERYSCHEDULEID_FLD + "," + PO_InvoiceDetailTable.INVOICEUMID_FLD + ")" + "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.INVOICELINE_FLD, OleDbType.Integer)); ocmdPCS.Parameters[PO_InvoiceDetailTable.INVOICELINE_FLD].Value = objObject.InvoiceLine; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.INVOICEMASTERID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[PO_InvoiceDetailTable.INVOICEMASTERID_FLD].Value = objObject.InvoiceMasterID; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.INVOICEQUANTITY_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.INVOICEQUANTITY_FLD].Value = objObject.InvoiceQuantity; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.UNITPRICE_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.UNITPRICE_FLD].Value = objObject.UnitPrice; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.VAT_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.VAT_FLD].Value = objObject.VAT; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.VATAMOUNT_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.VATAMOUNT_FLD].Value = objObject.VATAmount; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.IMPORTTAX_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.IMPORTTAX_FLD].Value = objObject.ImportTax; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.IMPORTTAXAMOUNT_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.IMPORTTAXAMOUNT_FLD].Value = objObject.ImportTaxAmount; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.INLAND_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.INLAND_FLD].Value = objObject.Inland; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.BEFOREVATAMOUNT_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.BEFOREVATAMOUNT_FLD].Value = objObject.BeforeVATAmount; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.CIFAMOUNT_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.CIFAMOUNT_FLD].Value = objObject.CIFAmount; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.CIPAMOUNT_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[PO_InvoiceDetailTable.CIPAMOUNT_FLD].Value = objObject.CIPAmount; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.NOTE_FLD, OleDbType.VarWChar)); ocmdPCS.Parameters[PO_InvoiceDetailTable.NOTE_FLD].Value = objObject.Note; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.PRODUCTID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[PO_InvoiceDetailTable.PRODUCTID_FLD].Value = objObject.ProductID; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.PURCHASEORDERMASTERID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[PO_InvoiceDetailTable.PURCHASEORDERMASTERID_FLD].Value = objObject.PurchaseOrderMasterID; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.PURCHASEORDERDETAILID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[PO_InvoiceDetailTable.PURCHASEORDERDETAILID_FLD].Value = objObject.PurchaseOrderDetailID; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.DELIVERYSCHEDULEID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[PO_InvoiceDetailTable.DELIVERYSCHEDULEID_FLD].Value = objObject.DeliveryScheduleID; ocmdPCS.Parameters.Add(new OleDbParameter(PO_InvoiceDetailTable.INVOICEUMID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[PO_InvoiceDetailTable.INVOICEUMID_FLD].Value = objObject.InvoiceUMID; 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(); } } } }
//************************************************************************** /// <Description> /// This method uses to get data from PO_InvoiceDetail /// </Description> /// <Inputs> /// ID /// </Inputs> /// <Outputs> /// PO_InvoiceDetailVO /// </Outputs> /// <Returns> /// PO_InvoiceDetailVO /// </Returns> /// <Authors> /// HungLa /// </Authors> /// <History> /// Thursday, September 29, 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 " + PO_InvoiceDetailTable.INVOICEDETAILID_FLD + "," + PO_InvoiceDetailTable.INVOICELINE_FLD + "," + PO_InvoiceDetailTable.INVOICEMASTERID_FLD + "," + PO_InvoiceDetailTable.INVOICEQUANTITY_FLD + "," + PO_InvoiceDetailTable.UNITPRICE_FLD + "," + PO_InvoiceDetailTable.VAT_FLD + "," + PO_InvoiceDetailTable.VATAMOUNT_FLD + "," + PO_InvoiceDetailTable.IMPORTTAX_FLD + "," + PO_InvoiceDetailTable.IMPORTTAXAMOUNT_FLD + "," + PO_InvoiceDetailTable.INLAND_FLD + "," + PO_InvoiceDetailTable.BEFOREVATAMOUNT_FLD + "," + PO_InvoiceDetailTable.CIFAMOUNT_FLD + "," + PO_InvoiceDetailTable.CIPAMOUNT_FLD + "," + PO_InvoiceDetailTable.NOTE_FLD + "," + PO_InvoiceDetailTable.PRODUCTID_FLD + "," + PO_InvoiceDetailTable.PURCHASEORDERMASTERID_FLD + "," + PO_InvoiceDetailTable.PURCHASEORDERDETAILID_FLD + "," + PO_InvoiceDetailTable.DELIVERYSCHEDULEID_FLD + "," + PO_InvoiceDetailTable.INVOICEUMID_FLD + " FROM " + PO_InvoiceDetailTable.TABLE_NAME + " WHERE " + PO_InvoiceDetailTable.INVOICEDETAILID_FLD + "=" + pintID; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand(strSql, oconPCS); ocmdPCS.Connection.Open(); odrPCS = ocmdPCS.ExecuteReader(); PO_InvoiceDetailVO objObject = new PO_InvoiceDetailVO(); while (odrPCS.Read()) { objObject.InvoiceDetailID = int.Parse(odrPCS[PO_InvoiceDetailTable.INVOICEDETAILID_FLD].ToString().Trim()); objObject.InvoiceLine = int.Parse(odrPCS[PO_InvoiceDetailTable.INVOICELINE_FLD].ToString().Trim()); objObject.InvoiceMasterID = int.Parse(odrPCS[PO_InvoiceDetailTable.INVOICEMASTERID_FLD].ToString().Trim()); objObject.InvoiceQuantity = Decimal.Parse(odrPCS[PO_InvoiceDetailTable.INVOICEQUANTITY_FLD].ToString().Trim()); objObject.UnitPrice = Decimal.Parse(odrPCS[PO_InvoiceDetailTable.UNITPRICE_FLD].ToString().Trim()); objObject.VAT = float.Parse(odrPCS[PO_InvoiceDetailTable.VAT_FLD].ToString().Trim()); objObject.VATAmount = Decimal.Parse(odrPCS[PO_InvoiceDetailTable.VATAMOUNT_FLD].ToString().Trim()); objObject.ImportTax = float.Parse(odrPCS[PO_InvoiceDetailTable.IMPORTTAX_FLD].ToString().Trim()); objObject.ImportTaxAmount = Decimal.Parse(odrPCS[PO_InvoiceDetailTable.IMPORTTAXAMOUNT_FLD].ToString().Trim()); objObject.Inland = Decimal.Parse(odrPCS[PO_InvoiceDetailTable.INLAND_FLD].ToString().Trim()); objObject.BeforeVATAmount = Decimal.Parse(odrPCS[PO_InvoiceDetailTable.BEFOREVATAMOUNT_FLD].ToString().Trim()); objObject.CIFAmount = Decimal.Parse(odrPCS[PO_InvoiceDetailTable.CIFAMOUNT_FLD].ToString().Trim()); objObject.CIPAmount = Decimal.Parse(odrPCS[PO_InvoiceDetailTable.CIPAMOUNT_FLD].ToString().Trim()); objObject.Note = odrPCS[PO_InvoiceDetailTable.NOTE_FLD].ToString().Trim(); objObject.ProductID = int.Parse(odrPCS[PO_InvoiceDetailTable.PRODUCTID_FLD].ToString().Trim()); objObject.PurchaseOrderMasterID = int.Parse(odrPCS[PO_InvoiceDetailTable.PURCHASEORDERMASTERID_FLD].ToString().Trim()); objObject.PurchaseOrderDetailID = int.Parse(odrPCS[PO_InvoiceDetailTable.PURCHASEORDERDETAILID_FLD].ToString().Trim()); objObject.DeliveryScheduleID = int.Parse(odrPCS[PO_InvoiceDetailTable.DELIVERYSCHEDULEID_FLD].ToString().Trim()); objObject.InvoiceUMID = int.Parse(odrPCS[PO_InvoiceDetailTable.INVOICEUMID_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(); } } } }