//************************************************************************** /// <Description> /// This method uses to add data to CST_ActCostAllocationDetail /// </Description> /// <Inputs> /// CST_ActCostAllocationDetailVO /// </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_ActCostAllocationDetailVO objObject = (CST_ActCostAllocationDetailVO)pobjObjectVO; string strSql = String.Empty; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand("", oconPCS); strSql = "INSERT INTO CST_ActCostAllocationDetail(" + CST_ActCostAllocationDetailTable.ALLOCATIONAMOUNT_FLD + "," + CST_ActCostAllocationDetailTable.ACTCOSTALLOCATIONMASTERID_FLD + "," + CST_ActCostAllocationDetailTable.COSTELEMENTID_FLD + "," + CST_ActCostAllocationDetailTable.DEPARTMENTID_FLD + "," + CST_ActCostAllocationDetailTable.PRODUCTIONLINEID_FLD + "," + CST_ActCostAllocationDetailTable.PRODUCTID_FLD + "," + CST_ActCostAllocationDetailTable.PRODUCTGROUPID_FLD + "," + CST_ActCostAllocationDetailTable.LINE_FLD + ")" + "VALUES(?,?,?,?,?,?,?,?)"; ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationDetailTable.ALLOCATIONAMOUNT_FLD, OleDbType.Decimal)); ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.ALLOCATIONAMOUNT_FLD].Value = objObject.AllocationAmount; ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationDetailTable.ACTCOSTALLOCATIONMASTERID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.ACTCOSTALLOCATIONMASTERID_FLD].Value = objObject.ActCostAllocationMasterID; ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationDetailTable.COSTELEMENTID_FLD, OleDbType.Integer)); ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.COSTELEMENTID_FLD].Value = objObject.CostElementID; ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationDetailTable.DEPARTMENTID_FLD, OleDbType.Integer)); if (objObject.DepartmentID > 0) { ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.DEPARTMENTID_FLD].Value = objObject.DepartmentID; } else { ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.DEPARTMENTID_FLD].Value = DBNull.Value; } ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationDetailTable.PRODUCTIONLINEID_FLD, OleDbType.Integer)); if (objObject.ProductionLineID > 0) { ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.PRODUCTIONLINEID_FLD].Value = objObject.ProductionLineID; } else { ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.PRODUCTIONLINEID_FLD].Value = DBNull.Value; } ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationDetailTable.PRODUCTID_FLD, OleDbType.Integer)); if (objObject.ProductID > 0) { ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.PRODUCTID_FLD].Value = objObject.ProductID; } else { ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.PRODUCTID_FLD].Value = DBNull.Value; } ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationDetailTable.PRODUCTGROUPID_FLD, OleDbType.Integer)); if (objObject.ProductGroupID > 0) { ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.PRODUCTGROUPID_FLD].Value = objObject.ProductGroupID; } else { ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.PRODUCTGROUPID_FLD].Value = DBNull.Value; } ocmdPCS.Parameters.Add(new OleDbParameter(CST_ActCostAllocationDetailTable.LINE_FLD, OleDbType.Integer)); ocmdPCS.Parameters[CST_ActCostAllocationDetailTable.LINE_FLD].Value = objObject.Line; 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 CST_ActCostAllocationDetail /// </Description> /// <Inputs> /// ID /// </Inputs> /// <Outputs> /// CST_ActCostAllocationDetailVO /// </Outputs> /// <Returns> /// CST_ActCostAllocationDetailVO /// </Returns> /// <Authors> /// HungLa /// </Authors> /// <History> /// Tuesday, February 21, 2006 /// </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 " + CST_ActCostAllocationDetailTable.ACTCOSTALLOCATIONDETAILID_FLD + "," + CST_ActCostAllocationDetailTable.ALLOCATIONAMOUNT_FLD + "," + CST_ActCostAllocationDetailTable.ACTCOSTALLOCATIONMASTERID_FLD + "," + CST_ActCostAllocationDetailTable.COSTELEMENTID_FLD + "," + CST_ActCostAllocationDetailTable.DEPARTMENTID_FLD + "," + CST_ActCostAllocationDetailTable.PRODUCTIONLINEID_FLD + "," + CST_ActCostAllocationDetailTable.PRODUCTID_FLD + "," + CST_ActCostAllocationDetailTable.PRODUCTGROUPID_FLD + "," + CST_ActCostAllocationDetailTable.LINE_FLD + " FROM " + CST_ActCostAllocationDetailTable.TABLE_NAME + " WHERE " + CST_ActCostAllocationDetailTable.ACTCOSTALLOCATIONDETAILID_FLD + "=" + pintID; Utils utils = new Utils(); oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString); ocmdPCS = new OleDbCommand(strSql, oconPCS); ocmdPCS.Connection.Open(); odrPCS = ocmdPCS.ExecuteReader(); CST_ActCostAllocationDetailVO objObject = new CST_ActCostAllocationDetailVO(); while (odrPCS.Read()) { objObject.ActCostAllocationDetailID = int.Parse(odrPCS[CST_ActCostAllocationDetailTable.ACTCOSTALLOCATIONDETAILID_FLD].ToString().Trim()); objObject.AllocationAmount = Decimal.Parse(odrPCS[CST_ActCostAllocationDetailTable.ALLOCATIONAMOUNT_FLD].ToString().Trim()); objObject.ActCostAllocationMasterID = int.Parse(odrPCS[CST_ActCostAllocationDetailTable.ACTCOSTALLOCATIONMASTERID_FLD].ToString().Trim()); objObject.CostElementID = int.Parse(odrPCS[CST_ActCostAllocationDetailTable.COSTELEMENTID_FLD].ToString().Trim()); if (!odrPCS[CST_ActCostAllocationDetailTable.DEPARTMENTID_FLD].Equals(DBNull.Value)) { objObject.DepartmentID = int.Parse(odrPCS[CST_ActCostAllocationDetailTable.DEPARTMENTID_FLD].ToString().Trim()); } else { objObject.DepartmentID = 0; } if (!odrPCS[CST_ActCostAllocationDetailTable.PRODUCTIONLINEID_FLD].Equals(DBNull.Value)) { objObject.ProductionLineID = int.Parse(odrPCS[CST_ActCostAllocationDetailTable.PRODUCTIONLINEID_FLD].ToString().Trim()); } else { objObject.ProductionLineID = 0; } if (!odrPCS[CST_ActCostAllocationDetailTable.PRODUCTID_FLD].Equals(DBNull.Value)) { objObject.ProductID = int.Parse(odrPCS[CST_ActCostAllocationDetailTable.PRODUCTID_FLD].ToString().Trim()); } else { objObject.ProductID = 0; } if (!odrPCS[CST_ActCostAllocationDetailTable.PRODUCTGROUPID_FLD].Equals(DBNull.Value)) { objObject.ProductGroupID = int.Parse(odrPCS[CST_ActCostAllocationDetailTable.PRODUCTGROUPID_FLD].ToString().Trim()); } else { objObject.ProductGroupID = 0; } objObject.Line = int.Parse(odrPCS[CST_ActCostAllocationDetailTable.LINE_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(); } } } }