public Boolean insertExpenditure(enExpenditure enExpenditure) { try { str = "INSERT INTO expenditure ("; str += "personalID,"; str += "expenditureType,"; str += "description,"; str += "calTax,"; str += "calSocialTax,"; str += "amount"; str += ")VALUES("; str += "@personalID,"; str += "@expenditureType,"; str += "@description,"; str += "@calTax,"; str += "@calSocialTax,"; str += "@amount"; str += ");"; Dbcmd = db.GetSqlStringCommand(str); db.AddInParameter(Dbcmd, "@personalID", DbType.Int32, enExpenditure.personalID); db.AddInParameter(Dbcmd, "@expenditureType", DbType.Int32, enExpenditure.expenditureType); db.AddInParameter(Dbcmd, "@description", DbType.String, enExpenditure.description); db.AddInParameter(Dbcmd, "@calTax", DbType.String, enExpenditure.calTax); db.AddInParameter(Dbcmd, "@calSocialTax", DbType.String, enExpenditure.calSocialTax); db.AddInParameter(Dbcmd, "@amount", DbType.Double, enExpenditure.amount); db.ExecuteNonQuery(Dbcmd); return true; } catch (Exception ex) { throw new Exception(ex.Message); } }
public Boolean updateExpenditure(enExpenditure enExpenditure) { try { str = "UPDATE expenditure SET "; str += "personalID=@personalID,"; str += "expenditureType=@expenditureType,"; str += "description=@description,"; str += "calTax=@calTax,"; str += "calSocialTax=@calSocialTax,"; str += "amount=@amount"; str += " WHERE expenditureID=@expenditureID;"; Dbcmd = db.GetSqlStringCommand(str); db.AddInParameter(Dbcmd, "@personalID", DbType.Int32, enExpenditure.personalID); db.AddInParameter(Dbcmd, "@expenditureType", DbType.Int32, enExpenditure.expenditureType); db.AddInParameter(Dbcmd, "@description", DbType.String, enExpenditure.description); db.AddInParameter(Dbcmd, "@calTax", DbType.String, enExpenditure.calTax); db.AddInParameter(Dbcmd, "@calSocialTax", DbType.String, enExpenditure.calSocialTax); db.AddInParameter(Dbcmd, "@amount", DbType.Double, enExpenditure.amount); db.AddInParameter(Dbcmd, "@expenditureID", DbType.Int32, enExpenditure.expenditureID); db.ExecuteNonQuery(Dbcmd); return true; } catch (Exception ex) { throw new Exception(ex.Message); } }